How to do number rounding to the nearest 2 decimals?

I made a local script that uses gui to show a value in the player, this value is a number value and whenever its changed the number value gets like, lots of decimals and makes the gui look not that good so i want to make it so the number value is rounded up to the nearest 2 decimals in the gui, but the real number value is still all those decimals its just changed in the gui. how can i do this? this is my script

local player = game.Players.LocalPlayer
local tweenservice = game:GetService("TweenService")
local PointMultiply = player:WaitForChild("PointMultiply")
local player = game.Players.LocalPlayer
local enableevent = game.ReplicatedStorage.Remotes.PEnableEvent
local playergui = player:FindFirstChild("PlayerGui")



while task.wait() do
	script.Parent.Text = "x".. tostring(PointMultiply.Value)
	
end


Try
script.Parent.Text = “x” … string.format(“%.2f”, PointMultiply.Value)

you could have a function that takes in your number and roundes it, like this

function round2decimals(a: number)
    a *= 100
    a = math.round(a)
    a /= 100
    return a
end

and then you pass to it PointMultiply.Value

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