I'm making a round based game, which ends once a timer reaches 0. Is the best way to do it to create a loop in a coroutine and take away 1 every second, or is there a better way?
✓ ANSWER ACCEPTED
Is this the best way to make a countdown timer?
1 answer
✓ Accepted answer
You can place the for loop in a spawn function() and any code below it should run.
spawn(function()
for i = 60, 0, -1 do
wait(1)
print(i .. " seconds left.")
end
end)
print("test")
1 comment
0
Thanks, this helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
just use a for loop
Right, I was thinking that it wouldn't work if there's code below it, but I forgot you can just break it.
repeats work
No need to break 'for loops'. After a for loop reaches it's max it will end the loop.
Right right, it's pretty late, I'm not thinking straight.