Player.CharacterAdded does not work and I need help with my specific situation

Hello developers! I need help with the Player.CharacterAdded event which is not firing. Here is my issue:

I’m making a racing game and I need to make my own checkpoint system. Here is how im doing it.

There is a main script that handles all of the checkpoints on the map. It then detects whenever any of them get touched. It then SHOULD save this and then whenever a character respawns, it should teleport to the last checkpoint touched by the player. The problem? The event is not firing! The print is not printing and the teleporting is not working either. I really need help with this because this is a really important system I need in my game. Anybody know how to fix this? Thanks!

Can you please paste your code, as it easier for us to edit/annotate it. Remember to enclose it in the 3 ` (ticks.)

local startGameEvent = game.ReplicatedStorage.Events.StartGame

local ServerStorage = game:GetService("ServerStorage")



startGameEvent.OnServerEvent:Connect(function(player, checkpoints, toggle)
	local character = player.Character
	local currentCheckpoint = player.Stats.CurrentCheckpoint

	currentCheckpoint.Value += 1
	
	local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
	if not checkpointData then
		checkpointData = Instance.new("Model", game.ServerStorage)
		checkpointData.Name = "CheckpointData"
	end
	
	local userIdString = tostring(player.UserId)
	local checkpointValue = checkpointData:FindFirstChild(userIdString)
	if not checkpointValue then
		checkpointValue = Instance.new("ObjectValue")
		checkpointValue.Name = userIdString
		checkpointValue.Parent = checkpointData
	end

	
	for i, checkpoint in pairs(checkpoints:GetChildren()) do
		checkpoint.Touched:Connect(function(touchPart)
			
			if checkpoint.Name == "Checkpoint"..currentCheckpoint.Value then
				print("hit checkpoint!")
				currentCheckpoint.Value += 1
				checkpointValue.Value = checkpoints:FindFirstChild("Checkpoint"..currentCheckpoint.Value)
				print(checkpointValue.Value)
				if not checkpointData then
					checkpointData = Instance.new("Model", game.ServerStorage)
					checkpointData.Name = "CheckpointData"
				end

				local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
				if not checkpoint then
					checkpoint = Instance.new("ObjectValue", checkpointData)
					checkpoint.Name = tostring(player.userId)
					player.CharacterAdded:Connect(function()
						character:WaitForChild("Torso").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame
						print("pls")
					end)
				end
			end
		end)
	end
	
end)

here is the entire script

so i made a script to fix your problem, it can be with any intvalue it doesn’t necessarily need to be in leaderstats but okay.

local CollectionService = game:GetService("CollectionService")
local Tagged = CollectionService:GetTagged("Checkpoint")

for i,v in pairs(Tagged) do
	v.Touched:Connect(function(hit)
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if not plr then return end
		
		local lstats = plr:FindFirstChild("leaderstats")
		if not lstats then return end
		
		local checks = lstats:FindFirstChild("Checkpoints")
		if not checks then return end
		
		if v.Name ~= "Checkpoint"..checks.Value then return end
		checks.Value += 1
	end)
end

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder",plr)
	leaderstats.Name = "leaderstats"
	
	local checkvalue = Instance.new("IntValue",leaderstats)
	checkvalue.Name = "Checkpoints"
	checkvalue.Value = 0
	
	plr.CharacterAdded:Connect(function(char)
		local checkpoint = workspace:FindFirstChild("Checkpoint"..checkvalue.Value)
		if not checkpoint then return end
		
		char:PivotTo(CFrame.new(checkpoint.Position + Vector3.new(0,2,0),checkpoint.Orientation))
	end)
end)

you just need to tag your checkpoints with the checkpoint tag.
there is another way of doing this though:

by creating teams(set each team so that it can’t be picked at the start), and adding spawnpoints, setting their team to the teamcolors and turning the modify team on touch boolean to true will automatically spawn players like checkpoints.

also this was to show you that it is easier like this, but obviously you have to modify this a bit to fit with your game started event etc.