Hello
I'm currently trying to get the amount of health remaining and put it in a TextLabel. However, I don't know how to make it like, "live". The current script I have doesn't update when I change my health. There is also a TextLabel I try to change the text color of whenever the health is below 50, 25 or even equal to 0.
if plr.Character.Humanoid.Health <= "50" then sta.healcolor.TextColor3 = BrickColor.new("245, 230, 15") end if plr.Character.Humanoid.Health <= "25" then sta.healcolor.TextColor3 = BrickColor.new("255, 95, 3") end if plr.Character.Humanoid.Health == "0" then sta.healcolor.TextColor3 = BrickColor.new("255, 0, 0") sta.healcolor.Text = "Dead" end sta.health.Text = plr.Character.Humanoid.Health
Please give me help for this. By the way, http://prntscr.com/iomkfu
In a LocalScript, you'll have to use RenderStepped or HealthChanged.
You can search them up on the Roblox wiki.
local player = game.Player.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local hum = char.Humanoid hum.HealthChanged:Connect(function(health) sta.Health.Text = health if health <= 50 then stat.healcolor.TextColor3 = Color3.fromRGB(245,230,15) end if health <= 25 then stat.healcolor.TextColor3 = Color3.fromRGB(255,93,3) end if health == 0 then stat.healcolor.Text = 'Dead' stat.healcolor.TextColor3 = Color3.fromRGB(255,0,0) end end)