humanoid.Died from local script?
1 | local plr = game.Players.LocalPlayer |
2 | repeat wait( 1 ) until plr.Character |
3 | local chr = plr.Character |
5 | chr.Humanoid.Died:Connect( function () |
6 | print ( "Character died" ) |
7 | plr.CharacterAdded:Wait() |
8 | print ( "Character respawned" ) |
This is the first code before editing
01 | local plr = game.Players.LocalPlayer |
02 | repeat wait( 1 ) until plr.Character |
03 | local chr = plr.Character |
05 | chr.Humanoid.Died:Connect( function () |
06 | print ( "Character died" ) |
07 | plr.CharacterAdded:Wait() |
08 | print ( "Character respawned" ) |
11 | chr:WaitForChild( "Humanoid" ) |
This is the code after editing
Seems to be working right, but when player died again, function is not working in both codes. How do I detect when humanoid died from a local script properly so this function can work forever? I need this script to be located in the player scripts, not character scripts.