Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is this the best way to make a countdown timer?

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?

5 comments

0

just use a for loop

0

Right, I was thinking that it wouldn't work if there's code below it, but I forgot you can just break it.

0

repeats work

0

No need to break 'for loops'. After a for loop reaches it's max it will end the loop.

0

Right right, it's pretty late, I'm not thinking straight.

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.