I have a math.floor script which rounds the number and adds SI prefixes at the end, but im trying to figure out to leave 2 decimals remaining. For example 1240.1245435, would be 1.24k+, instead of 1k+. Please help!
local plr = game.Players.LocalPlayer local lstats = plr:WaitForChild("leaderstats") local doritos = lstats:WaitForChild("Doritos") local coinslabel = script.Parent while true do -- always add bigger numbers first wait() if doritos.Value >= 1000000000000000000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000000000000000000) .. "o+ Doritos!" -- 1,000,000,000,000,000,000,000,000,000 / 1o+ elseif doritos.Value >= 1000000000000000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000000000000000) .. "sp+ Doritos!" -- 1,000,000,000,000,000,000,000,000 / 1sp+ elseif doritos.Value >= 1000000000000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000000000000) .. "sx+ Doritos!" -- 1,000,000,000,000,000,000,000 / 1sx+ elseif doritos.Value >= 1000000000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000000000) .. "qn+ Doritos!" -- 1,000,000,000,000,000,000 / 1qn+ elseif doritos.Value >= 1000000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000000) .. "qd+ Doritos!" -- 1,000,000,000,000,000 / 1qd+ elseif doritos.Value >= 1000000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000000) .. "t+ Doritos!" -- 1,000,000,000,000 / 1t+ elseif doritos.Value >= 1000000000 then coinslabel.Text = math.floor(doritos.Value / 1000000000) .. "b+ Doritos!" -- 1,000,000,000 / 1b+ elseif doritos.Value >= 1000000 then coinslabel.Text = math.floor(doritos.Value / 1000000) .. "m+ Doritos!" -- 1,000,000 / 1m+ elseif doritos.Value >= 1000 then coinslabel.Text = math.floor(doritos.Value / 1000 ) .. "k+ Doritos!" -- 1,000 / 1k+ elseif doritos.Value <= 1000 then coinslabel.Text = doritos.Value .. " Doritos!" -- <1,000 / <1k+ end end
I think you're looking for a function like this:
local function floor2Decimals(x) return math.floor(x / .01) * .01 end