Humanoid.Health
is a floating-point value, (aka a Number), so it will most likely never be exactly 0. Also, there exists a Died
event for Humanoids, so you don't have to check the health at all. GetPlayerFromCharacter
is a method of Players, not a Humanoid.
Really, this could be better done using the PlayerAdded
and CharacterAdded
Events, so I'll give you a fixed version of your code, and a version using those two:
01 | h = script.Parent:FindFirstChild( "Humanoid" ) |
03 | player = Game.Players:GetPlayerFromCharacter(script.Parent.Parent) |
05 | x = player:WaitForChild( "Ingame" ) |
07 | h.Died:connect( function () |
1 | Game.Players.PlayerAdded:connect( function (player) |
2 | local x = player:WaitForChild( "Ingame" ) |
3 | player.CharacterAdded:connect( function (character) |
5 | character.Humanoid.Died:connect( function () |