Problems about maths with a timer

hello there, as the title says, im having trouble trying to make a timer that shows the milisecs. here’s how i do all the maths:

local roundTime = 500
	repeat
		wait(.1)
		roundTime -= 1
	until roundTime == 0 or Valores.PR.Value == Valores.PTW.Value -- runs the timer until it reaches 0 or when all the players have won.
	if roundTime ~= 0 and actualRoundTime > 150 then -- if all players have won, then the time on the next round will be much lower than roundTime substracted by .5
		roundTime = math.floor(actualRoundTime-((roundTime * .1)+5))
		actualRoundTime = roundTime
	elseif roundTime == 0 and actualRoundTime > 150 then -- if the round ended because time ended, then it'll just substract .5 to the roundTime
		roundTime = actualRoundTime-5
		actualRoundTime = roundTime
	else -- lower cap of time
		roundTime.Value = 150
		actualRoundTime = 150
	end

the problem here comes when i want to change the milisecs to seconds, since for that i just need to do milisecs * .1, but when i do that, it prints this:
image

i also tried with math.round(milisecs) * .1 but it ends up like the same.

thanks to everyone who replies :DD (and sorry if i have bad grammar, i don’t speak english)

1 Like

use:

string.format("%f.1", [NUMBER HERE])
2 Likes

i tried this, using stats.Time.Text = string.format("%f.1", (t*.1)) but it doesn’t work ://
image

First of all, I’d recommend you use task.wait() instead of wait(), wait takes 1/30 of a second more than task.wait().

Second of all, you can use the following function in order to truncate numbers to tenths:

local function truncateToTenths(x)
    return x-x%0.1
end

In order to get more decimals, you can use 0.01 if you want to truncate the number to hundredths, and so on.

1 Like

thanks for the tip about task.wait(), i didn’t know that it was faster than the actual wait().

i’ll try your method, hope it works :))

i tried this but it doesn’t seem to do anything :frowning:
image

OK, well I have another solution:

math.round(x*1000)/1000 -- 1000 if you want milliseconds

change the 10s to whatever decimal you want to round it to. This also rounds the number, if you don’t want to round the number, you should use math.floor() instead of math.round()

1 Like

already found another ecuation that solved my problem, i’ll still try your ecuation tho (since mine seems a little complex lol)

math.floor(t*.1).."."..t - (math.floor(t*.1)*10)

Anyway, thanks for the help, i don’t think i could have done this with the ideas that yall got lol

1 Like

sadly this doesn’t work either :confused:
image
again, thanks for helping me out, really appreciate it :DD