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

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

Asked by 7 years ago
Edited 7 years ago

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

01local function CharacterLoop(Player)
02    Player:LoadCharacter()
03    local Character = Player.Character
04 
05    local NewCharacter = game:GetService("ServerStorage"):WaitForChild("Clak"):Clone()
06    NewCharacter.Parent = game.Workspace
07    NewCharacter.Name = Player.Name
08    Player.Character = NewCharacter
09 
10    local CameraFixer = script.CameraFixer:Clone()
11    CameraFixer.Disabled = false
12    CameraFixer.Parent = Player:WaitForChild("PlayerGui")
13 
14    local Humanoid = Character:WaitForChild("Humanoid")
15 
View all 22 lines...

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

Log in to vote
0
Answered by 7 years ago

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.

01local Player = game.Players.LocalPlayer
02Player.CharacterAdded:connect(function(Character)
03        Character:WaitForChild("Humanoid").Died:connect(function()
04             local NewCharacter = game:GetService("ServerStorage"):WaitForChild("Clak"):Clone()
05NewCharacter.Parent = game.Workspace
06NewCharacter.Name = Player.Name
07Player.Character = NewCharacter
08 
09local CameraFixer = script.CameraFixer:Clone()
10CameraFixer.Disabled = false
11CameraFixer.Parent = Player:WaitForChild(“PlayerGui”)
12 
13NewCharacter:WaitForChild("Animate").Disabled = false
14        end)
15    end)

Also may need to make spacing look nicer

0
It didn't work when i ordered it that way either. pi3dot14 0 — 7y
0
What line was the error SilentGalaxZy 53 — 7y
0
There was no error, it just didn't fire. pi3dot14 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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

Answer this question