What do you want to achieve? When a player dies, run code
What is the issue? Code doesn’t run
What solutions have you tried so far? I tried using Humanoid.Changed and Humanoid:GetPropertyChangedSignal(“Health”), and checking if the humanoid’s health is 0 or under, and I tried using Humanoid.Died.
local character = p.Character or p.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")
print(plr.Name.." has died")
Sometimes it messes up and seems to not work properly.
Alternatively, I think you could check
A third option I could suggest is checking this post -
The player or character may get added before the script loads, therefore not being detected by it. Since the script is related to the player character, you can parent it to StarterPlayer.StarterCharacterScripts to ensure it runs every time the character loads, then your script can be simplified to:
local Character = script.Parent --the script will be copied inside the character
local Humanoid = Character:WaitForChild("Humanoid")