Using this for a timer I'm making.
So say for example, I have a script read a number from a value object, holding an amount of seconds. Then the script would print in the output the amount of minutes:seconds that would equal. I'm having trouble thinking of something that can do that. Help is appreciated.
I just wrote one earlier today, actually.
Seconds/60 == minutes
. Chop of the fractional part with math.floor
and you have your minutes. Get the remainder of seconds using Seconds%60
.
For formatting, you have to add in an extra '0' when the minutes or seconds are less than 10:
local time = secondsValueObject.Value --By the way, I suggest using an IntValue as opposed to a NumberValue for this. local seconds, minutes = time%60, math.floor(time/60) local timerDisplayText = (minutes < 10 and "0" or "") .. minutes .. ":" .. (seconds < 10 and "0" or "") .. seconds