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

Why is the Humanoid.Died Event Not Firing on my Custom Character? [SOLVED]

So I'm trying to make it so that when the player dies, they respawn:

local function CharacterLoop(Player)
	Player:LoadCharacter()
	local Character = Player.Character

	local NewCharacter = game:GetService("ServerStorage"):WaitForChild("Clak"):Clone()
	NewCharacter.Parent = game.Workspace
	NewCharacter.Name = Player.Name
	Player.Character = NewCharacter
	
	local CameraFixer = script.CameraFixer:Clone()
	CameraFixer.Disabled = false
	CameraFixer.Parent = Player:WaitForChild("PlayerGui")
	
	local Humanoid = Character:WaitForChild("Humanoid")	
	
	NewCharacter:WaitForChild("Animate").Disabled = false
	
	Humanoid.Died:connect(function(deadPlayer)
		wait(2)
		CharacterLoop(Player)
	end)
end

However, the Died event does not fire at all. The Clak contains a HumanoidRootPart, a Head, and a Torso, and all of its parts are welded.

EDIT: If it helps, the model does not break apart upon death.

2 answers

You formed the function the wrong way, I am doing this on my phone so u may need to debug it a little bit, looks good so far thought.

local Player = game.Players.LocalPlayer
Player.CharacterAdded:connect(function(Character)
		Character:WaitForChild("Humanoid").Died:connect(function()
			 local NewCharacter = game:GetService("ServerStorage"):WaitForChild("Clak"):Clone()
NewCharacter.Parent = game.Workspace
NewCharacter.Name = Player.Name
Player.Character = NewCharacter

local CameraFixer = script.CameraFixer:Clone()
CameraFixer.Disabled = false
CameraFixer.Parent = Player:WaitForChild(“PlayerGui”)

NewCharacter:WaitForChild("Animate").Disabled = false
		end)
	end)

Also may need to make spacing look nicer

3 comments

0

It didn't work when i ordered it that way either.

0

What line was the error

0

There was no error, it just didn't fire.

I figured it out, the humanoid was the humanoid of the previous character. Using newcharacter's humanoid fixed it.

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