-- Place: ServerScriptService.Checkpoints (Script) local Players = game:GetService("Players") local checkpoints = workspace:WaitForChild("Checkpoints") local start = checkpoints:WaitForChild("Start") assert(start:IsA("SpawnLocation"), "Checkpoints.Start must be a SpawnLocation") local function initialize(player: Player) player:SetAttribute("CheckpointIndex", 0) player.RespawnLocation = start end Players.PlayerAdded:Connect(initialize) for _, player in Players:GetPlayers() do initialize(player) end for _, checkpoint in checkpoints:GetChildren() do if not checkpoint:IsA("SpawnLocation") then continue end local index = checkpoint:GetAttribute("Index") assert(typeof(index) == "number", checkpoint.Name .. " needs numeric Index") checkpoint.Touched:Connect(function(hit) local character = hit:FindFirstAncestorOfClass("Model") if not character then return end local player = Players:GetPlayerFromCharacter(character) local humanoid = character:FindFirstChildOfClass("Humanoid") local root = character:FindFirstChild("HumanoidRootPart") if not player or not humanoid or humanoid.Health <= 0 then return end if not root or not root:IsA("BasePart") then return end if not ((root.Position - checkpoint.Position).Magnitude <= 10) then return end local previous = player:GetAttribute("CheckpointIndex") or 0 if index <= previous then return end player:SetAttribute("CheckpointIndex", index) player.RespawnLocation = checkpoint print(player.Name, "reached checkpoint", index) end) end