Checkpoints soemtimes decide not work at all and rejoining usally doesnt help

i barly know how to script and my game has this bug checkpoints wont work sometimes for some people or rarly teleport them to default spawn point (when they reset or die they go back were they were) and even rejoining seems to not work

spawn.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
		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)
				wait()
				character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
			end)
		end
		
		checkpoint.Value = spawn
	end
end)

Can you show the full script and the error message shown?

you nested your characteradded inside a touched event, it would make more sense to put it inside playeradded → characteradded and not nested in a touch event. As the other person mentioned, please provide more context.

i don’t know what you mean by that

this is the full script
image

I don’t know if I’m the only one of if u did something wrong here but i cannot see the full script and instead see this:

So can’t really help you right now.