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.
local text = script.Parent.SurfaceGui.TextLabel
local number = math.random(3)
i = 10
while i == 10 do
if number == 3 then
text.Text = "Now turn back :)"
wait(10)
text.Text = ""
local number = math.random(3)
print(number)
end
if number == 2 then
text.Text = "What are you gonna do now?"
wait(10)
text.Text = ""
local number = math.random(3)
print(number)
end
if number == 1 then
text.Text = "There's nothing here. Lol."
wait(10)
text.Text = ""
local number = math.random(3)
print(number)
end
end
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
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
local text = script.Parent.SurfaceGui.TextLabel
local number = math.random(3)
i = 10
while i == 10 do
if number == 3 then
text.Text = "Now turn back :)"
wait(10)
text.Text = ""
number = math.random(3)
print(number)
end
if number == 2 then
text.Text = "What are you gonna do now?"
wait(10)
text.Text = ""
number = math.random(3)
print(number)
end
if number == 1 then
text.Text = "There's nothing here. Lol."
wait(10)
text.Text = ""
number = math.random(3)
print(number)
end
end

1 comment
As you answered this, I fixed the script. Sorry lol!