How to make a timer

image
Hi! I am wanting to make a timer like this that shows the minute + second count left before something. Like instead of displaying 830 seconds left it shows 15: 30. Thank you - BMWLux

local function convertToMS(seconds)
local mins = math.floor(seconds / 60)
local secs = math.floor(seconds % 60)

local mTxt = (mins < 10 and "0"..mins) or mins
local sTxt = (secs < 10 and "0"..secs) or secs

return mTxt..":"..sTxt
end

There’s also a way to simplify this using string manipulation, which I’m too braindead to figure out right now, lol.

2 Likes

Wow ok thank you so much! I will reply if I find any issues but thank you!

1 Like