How do I make a timer that uses minutes and seconds? 00:00

Hello! I am working on a game and want to use a timer that uses minutes instead of having the seconds only. I have been trying for hours to do this but I cannot get it down. Thanks for the help!

1 Like

I’ve actually created a module to allow you to convert a number of seconds to a timer format. Read more here:

I recommend you use this because normally, you’d have to have many for loops within each other, and it just gets crazy. So, all you have to do with the module is iterate over the number of seconds and convert them each time with the module.

local function digital_format(n)
    return string.format("%d:%02d", math.floor(n/60), n%60)

The "%d" is a format specifier for digit, the "%02d" specifies at least two digits and zero-padding. So if the number were 9 it would be 09 in the string. If it were 10 it would just be 10.