Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

:Died() function not firing when player resets?

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

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)

1 comment

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.