roblox roundify code example

Example 1: how to round numbers roblox studio

local roundDecimals = function(num, places) --num is your number or value and places is number of decimal places, in your case you would need 2
    
    places = math.pow(10, places or 0)
    num = num * places
   
    if num >= 0 then 
        num = math.floor(num + 0.5) 
    else 
        num = math.ceil(num - 0.5) 
    end
    
    return num / places
    
end

print(roundDecimals(142.165, 2)) --> 142.17

Example 2: how to round numbers roblox studio

player.PlayerGui.Stats.Frame.Upgrades.UpgradeSpeed.Text = math.floor((player.Stats.Speed.Value / 100)) * 100

Tags:

Misc Example