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

Does anyone have a good way to convert an integer into a countdown?

Hi.

I was just wondering if anyone had a good way to convert an integer representing some seconds left for something (e.g., the time left until a round ends) into a countdown clock; for example, the integer 300 could be displayed as 5:00.

I have no idea where to start trying to make this, honestly; does anyone have anything?

Thanks.

2 comments

0

Try it your self. You're basically asking for the code to be written for you, which is selfish. This is a HELP site, not a REQUEST.

0

I was just asking @incapaz. :>

2 answers

✓ Accepted answer

I use this:

local function clock(int)
	return string.format("%d:%.2d", int/60,int%60)
end

Study Format if you don't understand the arguments. yw

1 comment

0

Thank you so much man! :D

Try this:

function TIME(t)
       local s = ((math.floor(t%60)))
       local m = (((math.floor(t/60)%60)))
       if s < 10 and s>=0 then s = '0'..s end
       return (m..':'.. s)
end

print(TIME(200)) -- 3 : 20

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