I'm trying to make a local script that resets some items in the player whenever they die. But for some reason, it functions only the first time the player dies and won't function after that.
local player = game.Players.LocalPlayer repeat wait() until player.Character local character = player.Character local humanoid = character:WaitForChild("Humanoid") humanoid.Died:connect(function() player.LegBroken.Value = false player.Bleeding.Value = false player.PlayerScripts.SprintScript.Disabled = false end)
A player’s character always deletes when it dies. This means that the Humanoid along with the other character’s objects will be deleted and a new character model spawns instead. To correct this, you must connect the event everytime that the character respawns:
player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() -- do stuff end) end)
Also you don’t need to define character and humanoid first.
Hope this helps.