CharacterAdded not firing when the player respawns

What I’m trying to achieve is making a Checkpoint script that teleports the player to their spawn point whenever their character respawns by using CharacterAdded.

local Character = script.Parent --The character of the player (this script is storted in StarterCharacterScripts)

local Player = game:GetService("Players"):GetPlayerFromCharacter(Character) 
local StageCounter = Player:WaitForChild("leaderstats"):WaitForChild("Stage") --An intvalue inside of the leaderstats folder

local CheckpointsFolder = workspace:WaitForChild("CheckpointsFolder") --The folder that stores all of the checkpoints

local function onRespawned()
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	HumanoidRootPart.CFrame = CheckpointsFolder:WaitForChild("Checkpoint"..StageCounter.Value):WaitForChild("Spawn").CFrame +,2,0) --I teleport the player to the checkpoint of the stage they're currently on
	print("test") --I print test to verify if this function was fired

Player.CharacterAdded:Connect(onRespawned) --I connect onRespawn to the CharacterAdded event so it fires whenever the player respawns after death.

In the output however, there is no sign of errors anywhere. I suspect that this is a logic error though upon further inspection, I can’t find anything. Any help would be appreciated.

1 Like

I think that since the script is parented to the character, its connections are removed upon respawn because that character (and the script) was removed. Thus the CharacterAdded event would not fire.


StarterCharacterScripts are ran every time the character is re-spawned.

Like GloriedRage said -

Your script creates a listener for re-spawns after the player spawns in, and gets removed as the character gets removed. So it would never fire.

So you could just teleport the player outside the function. Or move the script inside ServerScriptService and change it up a bit so that it works for all characters.


Thanks! Definitely an oversight on my part, since I completely forgot that it disconnects everything.