Loop a Script to reset a certain Value

So I made a Timer for my game, but I want after the Timer finishes (Timer hits 0) to first change a value to some text, and after restart the Timer repeating the process but I don’t know how to archive this.
The ServerScript I have right now:

local Timer = 900
local Minutes
local Seconds
while true do	
	for i = Timer, 0, -1 do
		Timer = i
		Minutes = math.floor(Timer / 60)
		Seconds = math.floor(Timer % 60)
		MapTime.Value = (string.format("%02d: %02d", Minutes, Seconds))
		wait(1)
	end
-- Here it should check if timer hit 0, 
--then change the MapTime.Value to some text and
-- then restart the timer again from 900
end

You will already know if the timer hit zero at any point after the for loop, because you don’t execute any code outside the for loop until it finishes. Therefore, you can just do MapTime.Value = "asdf" after the for loop, and then after the code inside the while loop is completed, it will restart the timer, and then when that timer is done, it will change MapTime.Value, and then restart the timer, and so on…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.