Hello! I am attempting to make a Text U.I that informs people of their Max Health but for some reason, it isn't working. Plus, my health U.I's Health Text is not rounding as it's supposed to.
Note
I did not make this health bar, I simply fixed it with some outside help.
function _G.round(n)
return n - math.floor(n) >= 0.5 and math.ceil(n) or n - math.floor(n) < 0.5 and math.floor(n)
end
wait(0.5)
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
Digit = script.Parent.Holder.HealthbarHolder.Digits
MaxDigits = script.Parent.Holder.HealthbarHolder.MaxDigits
Round = (_G.round(hum.Health)) -- Issue
MaxRound = (_G.round(hum.MaxHealth)) -- Issue
hum.Changed:connect(function()
script.Parent.Holder.HealthbarHolder.Healthbar.Size = UDim2.new(hum.Health/hum.MaxHealth,0,1,0)
Round = (hum.Health)
Digit.Text = "Health: "..(Round.."%")
MaxDigits.Text = "Max Health: "..(MaxRound.."%")
if hum.Health <= hum.MaxHealth*0.20 then
script.Parent.Holder.HealthbarHolder.Healthbar.BackgroundColor3 = Color3.new(255,0,0)
else
script.Parent.Holder.HealthbarHolder.Healthbar.BackgroundColor3 = Color3.new(0, 255, 0)
end
end)
