Im trying to make it so the text is the same as the health and it works, but i found out that there are decimals and i dont know how to fix that, can some1 help me this is my script so far
local hi = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
script.Parent.Text = hi.Humanoid.Health
game.Workspace:WaitForChild(game.Players.LocalPlayer.Name).Humanoid.HealthChanged:connect(function()
script.Parent.Text = hi.Humanoid.Health
end)
local hi = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name) script.Parent.Text = hi.Humanoid.Health game.Workspace:WaitForChild(game.Players.LocalPlayer.Name).Humanoid.HealthChanged:connect(function() local roundednum =Instance.new('IntValue') -- a Interger Value will only show up as a number, not decimals roundednum.Value = hi.Humanoid.Health -- change the value of the Interger Value, and it will round it up wait(.001) script.Parent.Text = roundednum.Value -- changes the text hi.Humanoid.Health = roundednum.Value -- (you can remove this if you want) it will change the player's health without decimals roundednum:remove() -- clears the rounded number end)
You can do math.floor
or math.ceil
. math.floor
rounds down, and math.ceil
rounds up.
Here is a example of what math.floor
does.
local heath = 48.7917 print(math.floor(health)) --This will print 48.
This is a example of what math.ceil
does.
local health = 63.2539 print(math.ceil(health)) --This will print 64.
Also, when writing scripts on this website, use a code block.