hello, so I’m making a timer that includes miliseconds. the issue is that when im formatting the miliseconds, it’ll include 2 zeros which is annoying this is my function
function convertToHMS(s)
local minutes = math.floor(s / 60)
local seconds = s % 60
local milliseconds = (seconds * 1000) % 1000
seconds = math.floor(seconds)
milliseconds = tostring(milliseconds)
return string.format("%02i:%02i.%02i", minutes, seconds, milliseconds)
end
any help is appreciated! If u have any questions then feel free to ask!
Your format string in string.format says to add two zeroes.
See the “Flags” (especially the 0 flag) and “Width” section (especially the example) of Strings | Roblox Creator Documentation for an explanation of why it’s adding two zeros and get a hint how you could remove that.