Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to detect if another player dies in a local script?

Asked by 3 years ago

Hi, I wanted to make a script where it destroys certain objects inside a player's character when they die but I can't seem to figure it out.

Here's my script:

game.Players.PlayerAdded:Connect(function(blr)
    blr.CharacterAdded:Connect(function(jar)
        jar:WaitForChild("Humanoid").Died:Connect(function()
            if jar:FindFirstChildOfClass("Humanoid"):FindFirstChild("CanBeSeen") and jar:FindFirstChild("seen") then 
                jar:FindFirstChildOfClass("Humanoid"):FindFirstChild("CanBeSeen"):Destroy()
                jar:FindFirstChild("seen"):Destroy()
            end
        end)
        kenactive(jar)
        print(blr.Name)
    end)
end)

and yes, I did some searching and found out that you can't use playeradded in a localscript so I tried childadded and it still didn't work.

0
why is there just a random if on line 4 justinjosh5 19 — 3y
0
its part of line 5 & 6. idk why he decided to put it in a separate line. JesseSong 3916 — 3y

Answer this question