Issues with my checkpoint system

So, I’m making a checkpoint system for my game, but there’s a problem that’s been bugging me: The player simply keeps spawning at the world’s SpawnLocation instead of being moved automatically when the character is loaded.

The script:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local currentCheckpoint = ReplicatedStorage:WaitForChild("CurrentCheckpoint")

local module = {}

function module.loadCharacter(player)
	player:LoadCharacter()
	return player.CharacterAdded:Wait()
end

function module.loadAllCharacters()
	for _, player in ipairs(Players:GetPlayers()) do
		player:LoadCharacter()
	end
end

function module.spawnCharacter(player, destinationCFrame)
	local char = module.loadCharacter(player)
	if destinationCFrame then
		char:PivotTo(destinationCFrame)
	elseif currentCheckpoint.Value and currentCheckpoint.Value:IsA("BasePart") then
		local spawnPosition = currentCheckpoint.Value.CFrame * CFrame.new(0, 3.5, 0)
		char:PivotTo(spawnPosition)
	end
	return char
end

return module

The part where I think the error is:

function module.spawnCharacter(player, destinationCFrame)
	local char = module.loadCharacter(player)
	if destinationCFrame then
		char:PivotTo(destinationCFrame)
	elseif currentCheckpoint.Value and currentCheckpoint.Value:IsA("BasePart") then
		local spawnPosition = currentCheckpoint.Value.CFrame * CFrame.new(0, 3.5, 0)
		char:PivotTo(spawnPosition)
	end
	return char
end

Video:

Thank for all helping!

For my obby, I just created a checkpoint for the original spawn so when the player joins the game they auto-spawn at the original spawn. I avoided roblox spawns entirely. This also helps since you don’t have to worry about timing it with roblox spawns too. Try setting the “currentCheckpoint” value to the original spawn’s CFrame before or right after the player joins the game.

1 Like

Try using :SetPrimaryPartCFrame