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

Making a countdown GUI display minutes left? [Solved]

I'm attempting to have a countdown GUI for my game display how many minutes are remaining and removing the colon to display the remaining seconds after 2 minutes have past.

local countdown = 1
	for countdown = 120, 0, -1 do
	wait(0.1)
	TimeNumbers.Text = ":" ..countdown
	if TimeNumbers.Text "" then
		TimeNumbers.Text = ""..countdown
	end
	wait(1)
end

1 answer

✓ Accepted answer
for countdown=120,0,-1 do
	if countdown>=60 then
		TimeNumbers.Text=math.floor(countdown/60)..':'..('0'..(countdown%60)):sub(-2)
	else
		TimeNumbers.Text=countdown
	end
	wait(1)
end

This will display time time as minutes:seconds until 1:00, then it will count down from 59. ('0'..(countdown%60)):sub(-2) makes sure that the seconds are always two digits, by adding a '0' in front.

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