while true do
wait (1)
if script.Parent.Text == "0" then return end
script.Parent.Text = script.Parent.Text -1
end
I need the timer to reset at zero but I don't know how to do this there's no tutorials about this or anything, please help.
while true do
wait (1)
if script.Parent.Text == "0" then return end
script.Parent.Text = script.Parent.Text -1
end
I need the timer to reset at zero but I don't know how to do this there's no tutorials about this or anything, please help.
It is better to use a for loop instead as it is more efficient. Also, return is for functions. To end a loop, you would use break
Here is what you do:
local seconds = 60 -- change this to how long you want your timer to run for
while true do -- to loop the timer.
for i = seconds,0,-1 do
script.Parent.Text = tostring(i)
wait(1)
end
script.Parent.Text = seconds
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
10 comments
Then how could I loop it?
Just put a while true do loop around the for loop.
Where exactly would I put a while true do at what line?
put "while true do" at line 2 and "end" on line 8.
Do I put anything near while do true? Cause when I try it, it doesn't work.
What does the output say?
It says expected 'do', got 'script'.
I've edited the script above. Try using that.
Thank you so much it works just one more problem when I die it resets the whole timer is there any way I can fix this problem too?
Inside the ScreenGui that it's in, there should be a property named "ResetOnSpawn". Uncheck that.