Build a Whole Mini-Game: Finish-Line Obby
The short answer: An obby is an obstacle course. This one is small but complete: a few platforms, a finish pad, and three scripts you already know from this series. Touching the finish pad awards 50 points — once, thanks to a cooldown, not fifty times — the points show on the leaderboard, and DataStore saves them so they are still there when a player comes back tomorrow. Every script is printed whole, with a Copy button.
Build the course
- Start from a Baseplate place (page 1). The flat baseplate is your ground, and the SpawnLocation is where players appear.
- Add a handful of parts floating above the baseplate to make a short jumping course: a start platform near the spawn, three or four platforms to hop across, and one final platform. Color the final platform something bright.
- Select each platform part and turn its Anchored property on. Remember from the client-server guide: every part joins the physics simulation unless it is told otherwise — an unanchored platform falls out of the sky the moment the game starts.
- On the final platform, add one more flat part to stand on as the finish pad, and name it FinishPad in the Explorer. Names matter: your script finds its part through
script.Parent, and you find your scripts by the names you gave them.
Script 1 — the leaderboard
Exactly the script from page 6. Put a Script named Leaderboard in ServerScriptService:
-- Put this Script in ServerScriptService. Name it Leaderboard.
local Players = game:GetService("Players")
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
end
Players.PlayerAdded:Connect(onPlayerJoin)Script 2 — the finish pad
This is page 5's cooldown plate with a prize attached. Put a Script inside the FinishPad part:
-- Put this Script inside the FinishPad part.
local part = script.Parent
local Players = game:GetService("Players")
local cooldowns = {}
local COOLDOWN_TIME = 5
local PRIZE_POINTS = 50
local function onFinishTouched(otherPart)
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if not player then
return
end
local lastTouch = cooldowns[player] or 0
if tick() - lastTouch < COOLDOWN_TIME then
return
end
cooldowns[player] = tick()
local leaderstats = player:WaitForChild("leaderstats")
local points = leaderstats:WaitForChild("Points")
points.Value += PRIZE_POINTS
print(player.Name .. " finished and earned " .. PRIZE_POINTS .. " points!")
end
part.Touched:Connect(onFinishTouched)Why the cooldown is 5 seconds here: it stops a player standing on the pad from farming it — one finish, one prize, then the pad rests. In a bigger obby you would also send the player back to the start to run it again; even without that, the cooldown keeps the score honest.
Script 3 — saving
Exactly the script from page 6. Put a Script named SavePoints in ServerScriptService:
-- Put this Script in ServerScriptService. Name it SavePoints.
-- It works together with the Leaderboard script.
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetDataStore("PlayerPoints")
local function loadPoints(player)
local leaderstats = player:WaitForChild("leaderstats")
local points = leaderstats:WaitForChild("Points")
local success, savedPoints = pcall(function()
return pointsStore:GetAsync("Player_" .. player.UserId)
end)
if success and savedPoints ~= nil then
points.Value = savedPoints
end
end
local function savePoints(player)
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats then
return
end
local points = leaderstats:FindFirstChild("Points")
local success, errorMessage = pcall(function()
pointsStore:SetAsync("Player_" .. player.UserId, points.Value)
end)
if not success then
warn(errorMessage)
end
end
Players.PlayerAdded:Connect(loadPoints)
Players.PlayerRemoving:Connect(savePoints)Playtest it
- Run the game. Your Points should read 0 on the scoreboard.
- Run the course and step on the FinishPad. Watch Output for
... finished and earned 50 points!and the scoreboard for 50. - Stay standing on the pad for a few seconds. The score must not move — that is the cooldown working. Step off, wait out the 5 seconds, step on again: 100.
- To test saving in Studio, you need page 6's switch: in a test copy of the game, turn on Enable Studio Access to API Services (File > Experience Settings > Security). Finish once, stop the test, run it again — your saved points should load back. In the live game this works with no switch at all.
When it breaks: what to check, in order
- Nothing happens and Output is empty. Check where each script lives before you check what it says. Server scripts belong in ServerScriptService; the pad script belongs inside the FinishPad part. A script sitting in ReplicatedStorage never runs at all (page 2's lesson).
- There is red text in Output. Read it — it names the script and the line. The Script Analysis window also sums up a script's errors. Fix the first error first; later ones are often just its echo.
- The pad pays out over and over. Your cooldown is not doing its job. Check that the
cooldowns[player] = tick()line actually runs before the prize lines, and thatCOOLDOWN_TIMEis not 0. Also check the whole bottom of the script: if a never-endingwhileloop got pasted above the:Connect()line, the connection never happens — Roblox's own tutorial troubleshooting calls out exactly this loop-placement trap. - "Players" errors or a service will not load. The points tutorial's own troubleshooting tip: check that
"Players"ingame:GetService("Players")is capitalized and inside quotation marks. Names in Luau are case-sensitive —Pointsandpointsare different things (page 3). - Points change but never save in Studio. That is the API access toggle from page 6 — off by default in Studio, and only to be switched on in a test copy of your game, never the live one.
- You cannot tell where the script gives up. Sprinkle
print()checks: one at the top of the touch function ("the pad was touched"), one after the player is found, one after the prize is added. Run it and see which prints appear. The last print that shows tells you where the script stopped — the Output window is the most basic debugging tool there is, and this is exactly what it is for.
Make it yours: change PRIZE_POINTS, lengthen the course, add a second pad worth more. Every number a player can earn lives in these server scripts — which is where page 7 says numbers belong. When you are ready to show friends, the last page of this series covers publishing and keeping the game — and your account — safe.
This page is part of the Roblox Luau series:
1. Installing Roblox Studio ·
2. Your First Script ·
3. Luau Basics 1: Variables, Numbers, and Words ·
4. Luau Basics 2: Choices, Loops, and Functions ·
5. Making Things Happen: Events ·
6. Saving a Player's Progress ·
7. The Player Talks to the Server ·
8. Build a Whole Mini-Game ·
9. Stay Safe and Keep Your Game Yours
Sources (official only; read in full November 7, 2026):
- Roblox Creator Documentation, tutorial Else/if practice with giving points (Coding Fundamentals) (create.roblox.com/docs) — the leaderboard script; Touched with GetPlayerFromCharacter(); the troubleshooting notes used above ("Players" capitalized and in quotations; the while loop must sit at the bottom of the script; the Touched event must be connected).
- Roblox Creator Documentation, Data stores — GetDataStore, GetAsync, SetAsync, pcall wrapping, and the Studio API access toggle with its live-game warning.
- Roblox Creator Documentation, Securing the client-server boundary — the per-player cooldown pattern used by the finish pad.
- Roblox Creator Documentation, Scripting introduction and Script locations — the Output window as the basic debugging tool, the Script Analysis window, and why a script in the wrong container (such as ReplicatedStorage) never runs.
- Roblox Creator Documentation, Client-server runtime — every part participates in the physics simulation unless otherwise specified (why platforms are anchored).
- Roblox Creator Documentation, Create and publish games and places — the Baseplate template's SpawnLocation and baseplate.
All three scripts' logic was run on this machine against a small fake Roblox setup before this page was written: a test player finished the course for +50 points, an instant second touch was blocked by the cooldown, a later finish brought the total to 100, and the save/load round trip from page 6 was verified with the same rig. The scripts were also checked line by line against the documentation above. Checked November 7, 2026.