Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Having a number value round up to the nearest whole number?[SOLVED]

Asked by 6 years ago
Edited 6 years ago

I have a custom health bar and it has a text in the middle showing you your actual number of health. But when Roblox goes to regen your health it goes to the like 20th decimal place and im just like whaaa.

So I was wondering if there is a way to round up to the nearest whole number or not count any decimal places. Or maybe even how do you turn off health regen all together (I may want to custom script my own health regen)

Anyone have any ideas?

Thank you for your time. Sorry there isnt any code, I figured this question doesnt really need the code.

-- UPDATE

I decided to paste my code

wait(2)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local HealthBar = script.Parent.HealthBar
local Background = script.Parent

function Update()
    local HP = Humanoid.Health / Humanoid.MaxHealth
    script.Parent.HealthNumber.Text = Humanoid.Health
    HealthBar:TweenSize(UDim2.new(HP, 0, 1, 0), "Out", "Bounce", .1)
    wait(.1)
end

Update()

Humanoid.Changed:connect(Update)
0
math.floor(Humanoid.Health) User#17125 0 — 6y
0
^ math.floor(NUM+.5) TheeDeathCaster 2368 — 6y

Answer this question