game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
if char.Humanoid.Health < 1 then
plr.data.tp.Value = 0
end
end)
end)
Script Wont Work After Player Dies What am I Doing Wrong?
2 answers
Greetings, thank you for your post on Scripting Helpers.
Problem:
Your script is probably located in the incorrect place, if it is in StarterPlayer, you should move it to StarterCharacter. In StarterPlayer is will only run when you join.
How to solve:
Put the script in StarterCharacter.
Hope this works, -ecoszns
2 comments
That is Server Script, I guess... Because why he use PlayerAdded event to get Player instance when he can use LocalPlayer(Which is can only work for LocalScript).
I would of put it in ServerScriptService.
I see what the problem is. After the CharacterAdded function, add a wait(2) as a cooldown for the character and its children to load in. Like this:
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
wait(2) -- cooldown
if char.Humanoid.Health < 1 then
plr.data.tp.Value = 0
end
end)
end)
This error happens many times. You can't detect the health of the humanoid if it hasn't loaded in yet.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Try Humanoid.Died event instead https://developer.roblox.com/api-reference/event/Humanoid/Died