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

How do i make a countdown/up timer?

How do i make a timer? Thats it.

1 comment

0

pls help lol

1 answer

✓ Accepted answer

We don't make script at request on here, we ask questions about premade scripts. To do this, simply select an amount of seconds, let's say 100 for this example.

local Time = 100 -- What the timer should start at
local Goal = 0 -- What the goal is for the timer
local Interval = -1 -- How much it will decrease the timer every second. Change this to 1 if you want to count up.

-- Determine whether the loop counts up or down and start a loop
if Goal > Time then
	while Time < Goal do
		local Minutes = math.floor(Time / 60) -- Since time is amount of seconds the timer is on, and 1 minutes is 60 seconds we divide Time by 60. To avoid decimals we floor that number.
		local Seconds = Time - Minutes * 60 -- We see how many seconds are left after we take out the minutes.

		print(Minutes..':'..Seconds) -- Print this timer
		wait(1) -- Waits 1 second before the loop runs again
		Time = Time + Interval
	end
else
	while Time > Goal do
		local Minutes = math.floor(Time / 60) -- Since time is amount of seconds the timer is on, and 1 minutes is 60 seconds we divide Time by 60. To avoid decimals we floor that number.
		local Seconds = Time - Minutes * 60 -- We see how many seconds are left after we take out the minutes.

		print(Minutes..':'..Seconds) -- Print this timer
		wait(1) -- Waits 1 second before the loop runs again
		Time = Time + Interval
	end
end

You still need to add a way to display the timer yourself. Hope this helps. Keep what I said at the beginning of my post in mind!

This discussion is preserved as it was. New answers, comments, and votes are closed.