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

Milliseconds not working?

Hi guys! I have a time value in the format of 00:00:00000 I am trying to condense this down to 00:00:000 (Minutes, seconds and then milliseconds etc. up to 3 after the decimal place)

Any ideas why this is not working to do that? :(

function DigitalTime(TimeNum)
local Time = math.max(0, TimeNum)
local minutes = math.floor(Time / 60) % 60
local seconds = math.floor(Time) % 60
local m = tostring(math.floor((TimeNum%60)*100000))
local Timestring = string.format("d:d", minutes, seconds, m)
return Timestring
end



lol = 62.3034
A = DigitalTime(lol)
print(A)

It prints 1:02 Any help would be appreciated :) Thanks!

2 comments

0

Your over complicating things for the Timestring, string.format(minutes..":"..seconds..":"..m). As for the rounding to the third decimal place, I'm not quite sure.

0

This website cannot display these format strings. This website is broken.

1 answer

✓ Accepted answer

This website cannot display format strings because of how it interprets percent signs, but you are missing the third argument in the format string from what I can read.

" % 0 2 d : % 0 2 d : % 0 4 d " will work once you take out the spaces.

2 comments

0

Thank you, but now it displays it as 01:02:230340 which is too many :/

0

No problem - fixed it myself! :D

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