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

:Died() function not firing when player resets?

Asked by 6 years ago
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        if humanoid then
            print("1")
            humanoid.Died:connect(function()
                print("reset")
            end)
        end
    end)
end)

It prints 1, but not reset. All I'm doing is resetting the character, but it's not detecting that the player has died

2 answers

Log in to vote
1
Answered by 6 years ago

Don't do humanoid.Died:Connect(function() do humanoid.Died:Wait()

and use Connect not connect can't have

    end) -- can't do end with ) inside of ends without )
end

so

game:GetService("Players").PlayerAdded:Connect(function(plr) -- Gotta use get service 
    plr.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild"Humanoid"
        if hum then
            hum.Died:Wait()
            print("Something")
        end
    end)
end)
0
Doesn't work when you reset the first time. If you reset after that then it kinda works. How can i check if the players character has respawned after theyve died? I want to make something appear when the player respawns. I tried waiting for character but it didnt do anything NinjoOnline 1146 — 6y
Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

You have to create a Local Script that goes inside the characters model every time they re-spawn.

Make sure the Local Script is in StarterPlayerScripts

Local Script:

-- Put this in StarterPlayerScripts folder, it should go into the Player's character every time they re-spawn

  local humanoid = character:WaitForChild("Humanoid")
        if humanoid then
            print("1")
            humanoid.Died:connect(function()
                print("reset")
            end)
        end

Answer this question