How do i make a checkpont

One thing that confused me a lot ever since i began to script was obby checkpoints. And i wanted to know how i would be able to create one. If you could at least tell me the process of what is done to create such thing, PLEASE do.

1 Like

Here is a teleport script you put in ServerScriptService.
Name your checkpoints "Checkpoint1", "Checkpoint2", and so on.
If you want more than one checkpoint, just add more parts with the appropriate names.
The player will automatically respawn at the highest-numbered checkpoint they’ve touched.
Simple, but it works!

Remember if you don’t want them to collide with the checkpoint make the part cancollide = false

local Players = game:GetService("Players")
local checkpoints = {}

local function getCheckpointNumber(name)
	local n = string.match(name, "^Checkpoint(%d+)$")
	return n and tonumber(n)
end

for _, part in ipairs(workspace:GetChildren()) do
	local num = getCheckpointNumber(part.Name)
	if part:IsA("BasePart") and num then
		part.Touched:Connect(function(hit)
			local player = Players:GetPlayerFromCharacter(hit.Parent)
			if player then
				local current = checkpoints[player.UserId]
				if not current or num > current.num then
					checkpoints[player.UserId] = {num = num, cframe = part.CFrame}
				end
			end
		end)
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hrp = char:WaitForChild("HumanoidRootPart")
		local data = checkpoints[player.UserId]
		if data then
			hrp.CFrame = data.cframe + Vector3.new(0, 3, 0)
		end
	end)
end)

2 Likes

And if you want to do it yourself here is all the links:

2 Likes

you can basically change the spawnpoint of the player, for instance

local checkpoint = script.Parent

checkpoint.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild
if not humanoid then return end
humanoid.SpawnLocation = checkpoint

btw the checkpoint needs to be a spawn location
Hope this helps!
Sadly, if the player touched a checkpoint earlier than the one they’re on, it will still make it their checkpoint.

1 Like

wow… thanks so much man! This is actually extremely helpful. I really need to look at the API more.

2 Likes

No problem. Glad it helped you!