I'm trying to create a custom Health GUI to replace the default Health Coregui. Whenever I take damage, it shows decimal numbers after a digit, for example, 70.002944, but this happens only when the Health increases.
local Humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = Humanoid.Health Humanoid.HealthChanged:connect(function(health) local change = math.abs(currentHealth - health) local healthText = script.Parent.Frame.HealthText healthText.Text = "HEALTH:"..currentHealth currentHealth = health end)
Just try using math.floor
.
local Humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = Humanoid.Health Humanoid.HealthChanged:connect(function(health) local change = math.abs(currentHealth - health) local healthText = script.Parent.Frame.HealthText healthText.Text = "HEALTH:"..math.floor(currentHealth) currentHealth = health end)
local Humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = Humanoid.Health Humanoid.HealthChanged:connect(function(health) local change = math.abs(currentHealth - health) local healthText = script.Parent.Frame.HealthText rounded = math.floor(currentHealth) -- I rounded currenthealth using math.floor healthText.Text = "HEALTH:".. rounded -- and replaced your variable. currentHealth = health end)