What this script does
Advance a player only when a higher checkpoint is reached, query the current stage, or reset one session cleanly.
- Best for
- Obbies, route practice, tutorials, and staged progression in your own experience.
- Language
- Luau
- Version
- 1.0.0
- Validation
- Luau runtime tested
Official Luau 0.735 parsing and strict analysis pass, and the module is covered by the pure-module runtime behavior harness.
Included behavior
- Highest-stage-only progress
- Per-user state
- Reset and clear helpers
Install in the stated runtime
- 1Create a ModuleScript named Checkpoints.
- 2Paste the complete source and require it from a server or test Script in your own experience.
- 3Call reach from server-owned checkpoint touch logic and connect persistence separately if your project needs it.
Minimal usage example
local Checkpoints = require(script.Parent.Checkpoints)
local manager = Checkpoints.new()
manager:reach(player.UserId, 3)
print(manager:get(player.UserId))Example inputs and result
- Supply
- A player id and reached checkpoint number.
- Expect
- get reads the highest stored checkpoint in this in-memory manager.
These notes explain the example above. Read the complete source for every exported function and edge case before integrating it.
Complete source
No hidden import, minified block, or shortened loader.
--!strict
-- MIT License. In-memory checkpoint state for an obby or route you own.
local Checkpoints = {}
Checkpoints.__index = Checkpoints
function Checkpoints.new()
return setmetatable({ stages = {} :: { [number]: number } }, Checkpoints)
end
function Checkpoints:reach(userId: number, stage: number): boolean
local normalized = math.max(0, math.floor(stage))
local current = self.stages[userId] or 0
if normalized <= current then return false end
self.stages[userId] = normalized
return true
end
function Checkpoints:get(userId: number): number return self.stages[userId] or 0 end
function Checkpoints:reset(userId: number) self.stages[userId] = nil end
function Checkpoints:clear() table.clear(self.stages) end
return Checkpoints
355e69afb8512f822b4afb1ebdea1dff6fcc41403c1275ef9047af58690b74b9Outside this script’s scope
- Teleport characters
- Persist progress between servers
Found a problem or a better approach?
Tell us what failed, what you expected, and whether the issue happened in the Luau CLI or Roblox Studio. Suggestions for clearer types, safer server checks, or a more useful API are welcome.