How do I round to the nearest hundreth?

I was wondering how I could round a number to the nearest hundredth since sometimes the value would appear as like “0.850000000001” or something like that

image

I tried math.floor but that only rounds the nearest whole number

local plr = game.Players.LocalPlayer
local stat = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Normal Crystal")

while task.wait() do
	local num = stat.Value * 0.05
	script.Parent.Text = "Total Boost: +x"..num
end

Any help is appreciated!

Maybe try multiplying the number and ther round it, and after so just divide it without any roundings depending on what you need.

local plr = game.Players.LocalPlayer
local stat = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Normal Crystal")

while task.wait() do
	local num = stat.Value * 0.05
	script.Parent.Text = "Total Boost: +x" ..math.floor(num * 1000) / 1000
end

You can change it to math.round or math.clamp and the 1000 depending on the amount of digits you want to see.

1 Like

you can use sub or gsub or something like that to cut out parts of the num I think.

I don’t really use gsub a lot lool

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.