I am making a Half-Life 2 styled health GUI and it works except it will display decimals. So instead of showing 47 it shows something like 47.12515. Does anyone know how I could fix this?
Here is my script:
`local player = script.Parent.Parent.Parent.Parent.Parent
while true do hel = player.Character.Humanoid.Health if hel <= 25 then script.Parent.Text = hel script.Parent.BackgroundColor = BrickColor.new ("Bright red") else script.Parent.Text = hel script.Parent.BackgroundColor = BrickColor.new ("Bright green") end wait() end`
local player = script.Parent.Parent.Parent.Parent.Parent
Why? You should have this in a LocalScript and define the player as game.Players.LocalPlayer instead of doing Parent climbs.
As for your question, you're probably looking to use the math.floor() function which rounds the number down
Example:
local Number = 6.268 local WholeNumber = math.floor(Number) print(WholeNumber) --6