โ† Back to all scripts

Checkpoint System

Save a player's respawn location when they touch a checkpoint.

SystemsBeginnerScript inside Checkpoint Part
checkpoint-system.lua
-- Checkpoint System
local checkpoint = script.Parent
local debounces  = {}

checkpoint.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not player or debounces[player.UserId] then return end
    debounces[player.UserId] = true
    if player.RespawnLocation ~= checkpoint then
        player.RespawnLocation = checkpoint
        local orig = checkpoint.Color
        checkpoint.Color = Color3.fromRGB(80, 227, 164)
        task.wait(0.4)
        checkpoint.Color = orig
    end
    task.wait(1)
    debounces[player.UserId] = nil
end)
Related scripts in Systems
Basic Round SystemIntermediate โ†’Day/Night CycleBeginner โ†’Teleport to PlaceBeginner โ†’
Something broken or not working?
๐Ÿ”ง Try the AI Script Fixer โ†’