Your First Obby
Part of the Roblox Game Scripting section of Coddy's Lua journey. Lesson 25 of 25.
An obby (obstacle course) is the classic first Roblox game: get from the start to the finish without touching anything deadly. This one floats in the sky:
Start: the spawnLavaFloor: a wide gray platform. The two lava strips on it are in theLavafolder in workspace.Checkpoint: a SpawnLocation halfwayPath: a narrow walkwayFinish: the gold platform
One script in ServerScriptService runs the whole game, using everything from this course. One detail is new:
With two SpawnLocations (the start and the checkpoint), LoadCharacterAsync respawns the winner on their RespawnLocation, so point it back at the start before sending them there.
Challenge
HardMake the whole obby work from one script.
- In
PlayerAdded:leaderstatswith an IntValueWinsat0, andRespawnLocationset toworkspace.Start. - Every part in
workspace.Lavadefeats whoever touches it. - Touching
workspace.Checkpointmakes it the player's respawn point. workspace.Finishadds exactly 1 to Wins, sets RespawnLocation toworkspace.Startand callsLoadCharacterAsync().
Press Play and beat the obby twice: Wins shows 2. Then Check.
Try it yourself
local Players = game:GetService("Players")
-- 1. Every player gets leaderstats with Wins = 0, and starts at the start
Players.PlayerAdded:Connect(function(player)
end)
-- 2. Every part in workspace.Lava kills
-- 3. The checkpoint becomes the player's respawn point
-- 4. The finish: +1 win, then back to the start
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Roblox Game Scripting
2Loops and Functions
Row of PillarsStaircase BuilderTower BuilderCoin FactoryBlinking LightVanishing Bridge5Your First Game
Your First ObbyPractice on your own: Online Lua compiler