Hundredths does not display on SurfaceGui

I have tried to create a surface gui that displays minutes, seconds & hundredths. As far as i am sure this script should work fine and no errors were printed

image

script

local timerText = script.Parent

local timerDuration = 900

local function startTimer(timeLeft)
	print("TimerStarted")
	
	for count = timerDuration, 0, -1 do
		local minutes = math.floor(count / 60)
		local seconds = math.floor(count % 60)
		local hundret = math.floor(count % 1 * 100)
		
		timerText.Text = string.format("%02i:%02i.%02i", minutes, seconds, hundret)
		
		wait(1)	
		
		if count <=0 then
			script.Disabled = true
		end
	end
	
end

if script.Disabled == false then
	startTimer()
end

All that is displayed correctly are the minutes & seconds
image

well the problem is in the line:

local hundret = math.floor(count % 1 * 100)

any whole number modulo 1 is just going to come out as 0. I am not sure why you need milliseconds though as you are counting with a 1 second delay meaning that the milliseconds are always going to be 0 anyway.

1 Like

oh yeah thanks I can see the issue now with the

for count = timerDuration, 0, -1 do

should be -0.03.
thank you

1 Like