Need help with checkpoints

I’m making a checkpoint data store thing in a obby game for someone else, although I’m facing an issue where

  1. I don’t get teleported to the designated checkpoint and
  2. every time I purchase the skip stage developer product, It doesn’t do anything.

There are no errors, and I’m not sure what’s wrong with it.

local checkpoints = workspace:WaitForChild("Checkpoints")
local DataStore = game:GetService("DataStoreService")

local checkPointData = DataStore:GetDataStore("CheckpointData")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local level = Instance.new("IntValue")
	level.Name = "level"

	local levelNumber = checkPointData:GetAsync(player.UserId)

	if levelNumber then
		level.Value = levelNumber
	else if not levelNumber then
			level.Value = 1
		end
	end
	level.Parent = leaderstats

	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		wait()
		char.PrimaryPart.CFrame = checkpoints[level].Position

		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == level.Value + 1 then
					level.Value = level.Value + 1
					print(level.Value + 1)
				end
			end
		end)
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local leaderstats = player.leaderstats
	local level = leaderstats.level

	local success, errorMessage = pcall(function()
		checkPointData:SetAsync(player.UserId, level.Value)
	end)

	if errorMessage then
		error("Player ("..player.Name..")'s data couldn't be saved.")
	end
end)

if there is no errors then i suppose player.CharacterAdded isnt connect fact enough meaning that the character loads in before that gets runned so

i guess try

local character = player.Character
local hum = char:WaitForChild("Humanoid")
wait()
char.PrimaryPart.CFrame = checkpoints[level].Position

then have ur line

player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		wait()
		char.PrimaryPart.CFrame = checkpoints[level].Position

		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == level.Value + 1 then
					level.Value = level.Value + 1
					print(level.Value + 1)
				end
			end
		end)
	end)

Position > CFrame
Try changing that to: char.PrimaryPart.CFrame = checkpoints[level].CFrame

that wont change anything just change the way the player is looking when they spawn

I mean you can try this in order to attempt fixing it

Changing the quote to: char.PrimaryPart.CFrame = checkpoints[level.Value].CFrame (which I assume you already did)

and on the same line add .Value to read the actual value of level and wrap it with tostring :point_right: checkpoints[tostring(level.Value)].CFrame

Additionally make sure the checkpoint names are from 1 to x.
It’ll find the checkpoint based on your IntValue level

Let’s assume level.Value is 2. With the changes above it will convert your IntValue into a string and your checkpoint with the name 2 will be found. Before the change level was just a referenced instance

If that doesn’t work, let me know