I'm currently trying to make hearts disappear when the player's health reaches zero, but nothing happens at all.
I first made it so that the max health is 3.
Script:
wait(1)
local P = game.Players.LocalPlayer
P.Character.Humanoid.MaxHealth = 3
P.Character.Humanoid.Health = 3
Next, I put three hearts and a local script into each of them. Each script makes the heart disappear when the health is at that number. But none of them work. I tried adding a while true loop, but that didn't work either.
Here is the local script I used that would remove every heart when the health reaches zero:
wait(1)
local P = game.Players.LocalPlayer
if P.Character.Humanoid.Health == 3 then
script.Parent.Visible = true
end
if P.Character.Humanoid.Health == 2 then
script.Parent.Visible = false
end
The other local scripts are similar, but they only remove the heart that they are in.

9 comments
did you try P.Character.Humanoid.Health.Changed:Connect(function()
It gives me an error saying "Players.CaptainAlien132.PlayerGui.Hearts.HeartC.LocalScript:4: attempt to index field 'Health' (a number value)"
Wouldn't your initial script constantly raise the players health back to 3? Shouldnt that be only on Connect not on a loop
How would it change the health? The first script doesn't loop meaning it happens once.
oh im mistaken, I apologize.
It's okay
will u accept an answer for the question
If it works, then yes.
changed event is a property of instances, Health is a number value, use
P.Character.Humanoid.Changedevent, notP.Character.Humanoid.Health.Changed.