[FIXED BY ME] I made a script for a randomly generated sign, not switching text. Why?
Asked by
4 years ago Edited 4 years ago
This question has been solved by the original poster.
So, I'm making a sign that every 1 minutes (I know, my script says 10 seconds, that's just for making testing easier) It will change text. The first time the script runs, it randomly picks a line of text, Which works. But the second time it runs, it prints the randomly generated number correctly but the text on the sign does not change. Heres my code.
01 | local text = script.Parent.SurfaceGui.TextLabel |
03 | local number = math.random( 3 ) |
08 | text.Text = "Now turn back :)" |
11 | local number = math.random( 3 ) |
16 | text.Text = "What are you gonna do now?" |
19 | local number = math.random( 3 ) |
24 | text.Text = "There's nothing here. Lol." |
27 | local number = math.random( 3 ) |
Thank you for helping :)
Not gonna lie, I did a dumb. If anyone is curious, on the lines where I 'Redifined" number I typed 'local' before, like this
1 | local number = math.random( 3 ) |
this was creating a new variable, I had to remove the local to fix the script, so now the script looks like this
01 | local text = script.Parent.SurfaceGui.TextLabel |
03 | local number = math.random( 3 ) |
08 | text.Text = "Now turn back :)" |
11 | number = math.random( 3 ) |
16 | text.Text = "What are you gonna do now?" |
19 | number = math.random( 3 ) |
24 | text.Text = "There's nothing here. Lol." |
27 | number = math.random( 3 ) |