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

How to make countdown in : format? Make it into minutes rather than seconds.

Hello, So I know how to make the countdown timer and I am fine with that. But how would I get it to a format of :. IE. If the round was 2 minutes, how would I get it to be 2:00?

for i = 10,0,-1 do
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = i

1 answer

Simple enough. Most people usually write a crap ton of code just to do that, but here's my very easy solution:

string.format returns a formatted version of its variable number of arguments following the description given in the first argument; the format string. The format string follows the same rules as the ISO C function sprintf.

local seconds = 44
local minutes = math.floor(seconds / 60)

TextLabel.Text = string.format("%.2d:%.2d", minutes, seconds)

You can read more about format strings here: http://www.cplusplus.com/reference/cstdio/printf/

2 comments

0

%.2d:%.2d

0

If this helped, please consider marking my answer as accepted.

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