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

Humanoid death check only running once?

Asked by 4 years ago

Pretty simple premise here, this function is only running once. When I enter the game the first time my character dies it runs fine, but after another respawn it doesn't return anything. How could I make it run every time the character dies?

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait()
character:WaitForChild("Humanoid").Died:connect(function()
    print("Player was killed")
end)

Any help would be greatly appreciated. It's probably a very simple solution I just couldn't see it.

2 answers

Log in to vote
0
Answered by 4 years ago

For me this works:

game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
    character:WaitForChild("Humanoid").Died:Connect(function()
        --The stuff you wanna do
    end)
end)
Ad
Log in to vote
0
Answered by 4 years ago

Hello I can help you with this, try using this:

while true do --This will look when the script is ended and then it will do the text below it
wait(0.1) --Use this to make sure it wont crash
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
    character:WaitForChild("Humanoid").Died:Connect(function()
        --What you want to happen if they die (PUT ON THIS LINE!)
    end)
end)

Answer this question