of     1   

chess123mate
#106539Thursday, August 16, 2007 3:43 PM GMT

Can you make a variable that any script (even if there are multiple scripts) can all access? Ex. Script1 ------- global time = 0 do while true wait(1) time = time + 1 end Script2 ------- do while true if time = 60 then msg = Instance.new("Message") msg.Text = "A minute has passed since you started the game." msg.Parent = game.Workspace wait(4) msg.Parent = nil end I understand that there isn't a "global", at least - I don't think it is -- perhaps all variables default to a global value?
shanethe13
#106543Thursday, August 16, 2007 3:46 PM GMT

If I understand what you are saying correctly, you could try adding an intvalue in. It is basically a variable any script can access. I forget how to add one in though. Try hitting; Insert>Object>IntValue
chess123mate
#106746Thursday, August 16, 2007 5:46 PM GMT

...it kind of works, but I'm not sure. Isn't print("This is a statement.") supposed to go on to the Output window? Here's what I've got in Test1 and Test2 scripts (where that intvalue is 'ATime') ----------------------Test1 print("Opened Test1 Timer") do while true wait(1) game.Workspace.ATime.Value = game.Workspace.ATime.Value + 1 end -----------------------Test2 lval = 0 print("Opened Test2 Printout") do while true do while lval = val val = game.Worksapce.ATime.Value end print(val) lval = val end shouldn't that work? It's 2 different scripts and that ATime intvalue. In the output, it doesn't show anything!
chess123mate
#106776Thursday, August 16, 2007 5:57 PM GMT

OK - I just found my spelling error in 'val = game.Worksapce" rather than Workspace, and even tried using messages/hints, but still - nothing is coming up.
shanethe13
#106799Thursday, August 16, 2007 6:04 PM GMT

Try moving "do while true" to the line directly above the print commands. There wasn't any script defining when the print command should be initiated, so it wasn't doing anything.
chess123mate
#106862Thursday, August 16, 2007 6:23 PM GMT

what? you mean that Lua requires you to tell WHEN you want the command to be processed? I only want the print command to be done once, and after that I want the update print command to print when ever there was a time change, which I programmed. I've converted them to messages as well, but I also have the print included.
shanethe13
#106871Thursday, August 16, 2007 6:27 PM GMT

Yes, as far as I know, you need to define when a command is processed. Usually after a function such as "onTouched" or something of the sort. If you only want it to do the print command once. Try doing something like this. print = 1 if "print" == 1 then print() --Put print command here "print" = 0 --continue script I'm not sure if this will work, as I haven't tested it, but something only those lines should do the trick. Have you had privous experience in programming? Since for someone who just learn LUA, those are some pretty complicated scripts.
chess123mate
#106910Thursday, August 16, 2007 6:40 PM GMT

Well... Although I've done many years of basic programming (about 4 or 5), I'm just getting into the more complicated and up-to-date ones, like VB and in this case Lua. I tried doing this: do while true print("Hello World") end and it didn't work either... I don't get it, really. Perhaps the "Hello World" shows up elsewhere? As for the scripts complications... as I've said I've done programming before. It's just that I don't know everything about Lua yet... (but I will soon... :) ) I'm unsure if what you've said is true... I understand that with functions, like in OnFunction do ____, obviously it only occurs at certain times. But what about the simple statement, "print("Hello World!")" that shows up at the beginning of each script if you don't delete it? It is just 'run', isn't it? Also, I don't think you need If "print" == 1 then I think it's just If print == 1 then --what ever end ... AAH!!! I just realized my mistake! I'm so used to "Do ... while x = 3" That I didn't do "while true do" I did "do while true"! That should fix it up... and no you don't need to have an if/then statement. It doesn't make a bit of difference! That's just extra programming. You need functions to simulate events.
chess123mate
#106918Thursday, August 16, 2007 6:42 PM GMT

Thanks anyway, shanethe13!
shanethe13
#106938Thursday, August 16, 2007 6:46 PM GMT

Oh, I also missed that small mistake with the "while true do" statement :) I haven't done much with print commands, and every script I've seen had a function of some sort near the top. I'm also just learning LUA now, I've had experience with other languages such as basic, or sadscript, but this is my first time actually trying LUA.
chess123mate
#106952Thursday, August 16, 2007 6:50 PM GMT

I'd tell you if it works, but every time i try and go in the program crashes! I'm going to try a restart of the computer, and then if it doesn't work... I don't like the sounds of that! I might have to completely restart! (That is, restart since the last time I saved it on the hard drive!)
shanethe13
#106965Thursday, August 16, 2007 6:53 PM GMT

When it crashes do you get a Runtime-Error of any sort? And is it crashing when you launch Roblox Studio, or when you try to run the script?
chess123mate
#106972Thursday, August 16, 2007 6:56 PM GMT

It won't open. I click Visit Solo, and it eventually it comes up with a White screen, but it doesn't actually load. It "Isn't responding". I'm about to try a reboot, now.
shanethe13
#106989Thursday, August 16, 2007 7:01 PM GMT

[ Content Deleted ]
chess123mate
#106996Thursday, August 16, 2007 7:04 PM GMT

OK - that might save my place after all. I'll try it and report back...
chess123mate
#107004Thursday, August 16, 2007 7:06 PM GMT

YAY! IT WORKS!!! THANK YOU THANK YOU THANK YOU!!! Now to just figure out how to delete the scripts that are causing the error..
chess123mate
#107008Thursday, August 16, 2007 7:07 PM GMT

When I pressed "Play" - it froze up... very interesting...
Anaminus
Top 100 Poster
#107195Thursday, August 16, 2007 8:23 PM GMT

Here, you can do this all in one script: ------------------------------------------------------------------------------------------ Time = Instance.new("IntValue") --Creates a new IntValue Time.Value = 0 Time.Parent = game.Workspace function sayTheTime() if Time.Value >= 60 then msg = Instance.new("Message") msg.Text = "A minute has passed since you started the game." msg.Parent = game.Workspace wait(4) msg.Parent = nil Time.Value=0 --Resets the value to 0. end end while true do Time.Value = Time.Value+1 sayTheTime() wait(1) end ------------------------------------------------------------------------------------------ *This is going to display the message every minute. ?-Anaminus-?
chess123mate
#107222Thursday, August 16, 2007 8:33 PM GMT

yes, that would work, but it doesn't with what I'm trying to do. I want a timer that "runs in the background". Basically, how do I access that variable in other scripts? The "time" variable. The scripts aren't cooperating with me...
FunctionM
#227036395Tuesday, October 31, 2017 1:50 AM GMT

b1
FunctionM
#227036431Tuesday, October 31, 2017 1:51 AM GMT

b2
FunctionM
#227036471Tuesday, October 31, 2017 1:52 AM GMT

b3
FunctionM
#227036590Tuesday, October 31, 2017 1:56 AM GMT

b4

    of     1