Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have a timer gui model for my game but I need it to reset when it hits zero how do I do this?

Asked by 6 years ago
Edited 6 years ago
   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.

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago
Edited 6 years ago

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
0
Then how could I loop it? FreddydehNoob101 -3 — 6y
0
Just put a while true do loop around the for loop. UgOsMiLy 1074 — 6y
0
Where exactly would I put a while true do at what line? FreddydehNoob101 -3 — 6y
0
put "while true do" at line 2 and "end" on line 8. UgOsMiLy 1074 — 6y
View all comments (6 more)
0
Do I put anything near while do true? Cause when I try it, it doesn't work. FreddydehNoob101 -3 — 6y
0
What does the output say? UgOsMiLy 1074 — 6y
0
It says expected 'do', got 'script'. FreddydehNoob101 -3 — 6y
0
I've edited the script above. Try using that. UgOsMiLy 1074 — 6y
0
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? FreddydehNoob101 -3 — 6y
0
Inside the ScreenGui that it's in, there should be a property named "ResetOnSpawn". Uncheck that. UgOsMiLy 1074 — 6y
Ad

Answer this question