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 + Vector3.new(0,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 end 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.