Your First Obby
Part of the Roblox Game Scripting section of Coddy's Lua journey. Lesson 24 of 24.
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:
- Every player gets
leaderstatswith an IntValueWinsat0, and theirRespawnLocationisworkspace.Start. - Every part in
workspace.Lavadefeats whoever touches it. - Touching
workspace.Checkpointmakes it the player's respawn point. - Touching
workspace.Finishadds exactly 1 to Wins, sets the player's RespawnLocation toworkspace.Startand sends them there withLoadCharacterAsync(). Finishing again later adds another win.
Press Play and beat your obby, then Check. The test player runs it twice.
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