๐Ÿ”ด SIM LOCKDOWN ยท Episode 1 of 3 ยท See All Episodes
๐Ÿ”ด Episode 1 ยท Advanced ยท Ready to script

SIM LOCKDOWN
The Match Loop

Every party game needs a referee. In this episode you build the lobby and the invisible loop that runs round after round, waits for players, counts down and launches the match. By the end you have a working game shell other players can join.

๐Ÿง’ Ages 9+ โฑ๏ธ ~1 Hour ๐ŸŸฆ Roblox Studio โœ“ Free
๐Ÿง  State machines ๐Ÿ” while loops ๐ŸŒ RemoteEvents ๐Ÿ–ฅ๏ธ Server vs client ๐Ÿ“ฆ Attributes
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress 0 / 6 steps
๐ŸฆŠ
Lumo says: this is a bigger project than the obby, so we build it in three episodes. Do them in order. Episode 1 makes the game run, Episode 2 makes the maps, and Episode 3 adds the pushing and the final.
๐Ÿ“ฆ
Prefer to lay it out visually? The Roblox Mod Studio lets you place platforms and scripts in the browser, then download a model to drop into Studio. Every code block also has a Copy button.
1
๐Ÿงฐ
Set Up the Project
Create the folders, the shared Config and the RemoteEvent the game talks through
Active
๐ŸŽฏ
Goal for this step

Get a clean project structure so the server and the player screens can talk to each other.

๐Ÿ‘จโ€๐Ÿ‘ง
Parent note: Roblox games have two halves. The server runs the rules, and each player's computer runs the client. They swap small messages through a RemoteEvent. This step sets that up.

Build the structure

  • 1Open Roblox Studio with a new Baseplate. Delete the Baseplate and the SpawnLocation.
  • 2In ReplicatedStorage, right-click and add a RemoteEvent. Rename it ObbyEvent.
  • 3In ReplicatedStorage, add a ModuleScript called Config. This holds all your tuning numbers in one place.
  • 4In ServerScriptService, add a Script called ObbyServer.
  • 5In StarterPlayer → StarterPlayerScripts, add a LocalScript called ObbyClient.
Config (ModuleScript)
-- ReplicatedStorage/Config local Config = {} Config.MIN_PLAYERS = 2 -- need this many to start Config.START_COUNTDOWN = 15 -- seconds in the lobby Config.ROUND_TIME = 150 -- seconds per round Config.WALK_SPEED = 24 return Config
๐Ÿ’ก
A ModuleScript is a box of code you can require() from anywhere. Keeping the numbers here means you change them once, not in ten scripts.
๐Ÿง 
Knowledge Check
+15 XP
Where does the server script live, the one that runs the rules?
AStarterPlayerScripts
BServerScriptService
CReplicatedStorage
2
๐ŸŸ๏ธ
Build the Lobby
A big floating platform where players wait, and code that places them on it
Locked
๐ŸŽฏ
Goal for this step

A safe platform high in the sky, and a helper that moves any player onto it.

  • 1Insert a Part. In Properties set Size to 70, 2, 70 and Position to 0, 600, 0.
  • 2Tick Anchored so it never falls. Rename it LobbyFloor.
  • 3Now the code: when a player joins, we load their character and move it to the lobby.
ObbyServer (Script)
local Players = game:GetService("Players") -- players do not spawn on their own; we move them Players.CharacterAutoLoads = false local lobbyCF = CFrame.new(0, 605, 0) -- above the floor local function placeAt(player, cf) local character = player:LoadCharacterAsync() character:PivotTo(cf) return character end Players.PlayerAdded:Connect(function(player) placeAt(player, lobbyCF) end)
๐Ÿ”ง
Stuck? If players fall through the air, check the floor is Anchored. If nobody appears, check CharacterAutoLoads is set to false (that is lowercase, not "false").
๐Ÿ“Fill in the Concept+15 XP
Players wait in the until there are enough of them. When the match is about to start, a short ticks down.
๐Ÿง 
Knowledge Check
+15 XP
Why do we set CharacterAutoLoads = false?
ASo we control when and where each player spawns
BTo make the game load faster
CTo stop players from jumping
3
๐Ÿ”
The Match Loop
One forever-loop that runs the whole game, stage by stage
Locked
๐ŸŽฏ
Goal for this step

An endless loop that repeats the match forever, changing a "phase" as it goes.

Real party games never stop. When one match ends, the next begins. We do that with a while loop and a phase word that tells us where we are:

ObbyServer (Script)
local phase = "lobby" -- lobby -> start -> race -> final while true do phase = "lobby" waitForPlayers() -- step 4 fills this in phase = "start" countdown() -- step 4 fills this in phase = "race" runRound() -- step 5 fills this in end
๐Ÿ’ก
Why while true? It means "keep doing this forever". Each time round the loop is one whole match. Changing phase is how the game knows which stage it is in.
โŒจ๏ธ
Code Challenge
+20 XP

Fill in the three blanks that make the loop run forever:

do runRound()
Hint: the keyword that starts a loop, the value that is always true, and the keyword that closes a block.
๐Ÿ”ข
Put the phases in order
+15 XP

Click the match phases in the order the game runs them:

Lobby (wait for players)
Countdown
Race
Final
๐Ÿง 
Knowledge Check
+15 XP
What does the phase variable tell us?
AHow many players are online right now
BWhich stage of the match we are in
CHow much time is left
4
โฑ๏ธ
Wait, Count Down, Launch
Fill in the two helper functions that start a match
Locked
๐ŸŽฏ
Goal for this step

Wait until 2 players are ready, show a countdown, then send everyone to the course.

  • 1waitForPlayers just waits until the player count reaches Config.MIN_PLAYERS.
  • 2countdown ticks from 15 to 0, writing the number onto a player attribute so every screen can show it.
ObbyServer (Script)
local function waitForPlayers() while #Players:GetPlayers() < Config.MIN_PLAYERS do task.wait(1) end end local function countdown() for i = Config.START_COUNTDOWN, 1, -1 do for _, player in ipairs(Players:GetPlayers()) do player:SetAttribute("Countdown", i) end task.wait(1) end end
๐Ÿ’ก
What is an attribute? A tiny value you stick onto a player or a part. It copies to every player's screen automatically, so the client can read player:GetAttribute("Countdown") and show it. No messages needed.
๐Ÿง 
Knowledge Check
+15 XP
How does the countdown reach every player's screen?
AWe print it in the Output window
BWe set a player attribute the client reads
CWe change the Lighting properties
5
๐Ÿ
Run One Round
A placeholder round that moves everyone to the course and back
Locked
๐ŸŽฏ
Goal for this step

A real round function that the loop can call. Episode 2 builds the actual course it drops you onto.

  • 1Make a start platform far away, for example a Part at 0, 0, 0 sized 30, 2, 22.
  • 2Set startCF to a CFrame above it, then move every player there at the start of a round.
ObbyServer (Script)
local startCF = CFrame.new(0, 5, 0) local function runRound() for _, player in ipairs(Players:GetPlayers()) do placeAt(player, startCF) -- onto the course player:SetAttribute("Running", true) end task.wait(Config.ROUND_TIME) -- the race would run here for _, player in ipairs(Players:GetPlayers()) do player:SetAttribute("Running", false) end end
๐Ÿ’ก
Right now the round just waits. That is on purpose. Episode 2 replaces the empty wait with a real course you race across.
โŒจ๏ธ
Code Challenge
+20 XP

Loop over every player and move them to the start:

for _, player in (Players:GetPlayers()) do local cf = .new(0, 5, 0) placeAt(player, cf) end
Hint: the iterator for a list, and the object that describes a position and facing.
๐Ÿง 
Knowledge Check
+15 XP
What does CFrame.new(0, 5, 0) describe?
AA colour
BA size of 0 by 5 by 0
CA position in the world, 5 studs up
6
๐Ÿงช
Test With Two Players
Run the game with a second player and watch a full loop
Locked
๐ŸŽฏ
Goal for this step

Confirm the loop works: two players, a countdown, then both get moved to the course.

  • 1Click Test at the top, then Clients and Servers, and set Players to 2.
  • 2Click Start. You should see two characters standing on the lobby floor.
  • 3Within a second the countdown starts. When it hits 0 both players jump to the course platform.
  • 4After 150 seconds the round ends and the loop begins again. That is one full match.
๐Ÿ”ง
Nothing moves? Check the Output window for red errors. The most common one is a typo in a function name, or a Config value that is still a string.
๐Ÿ‘จโ€๐Ÿ‘ง
Try this together: change Config.START_COUNTDOWN to 3 and start again. The match begins much faster. That is the power of keeping numbers in one Config file.
๐Ÿง 
Knowledge Check
+15 XP
How many players must be present before the match starts in this episode?
A2, set by Config.MIN_PLAYERS
B8, one for each episode
CAt least 10
๐ŸŽ‰โœจ๐ŸŽŠโญ๐ŸŽ‰
The Loop Runs!

You built a lobby, a match loop and a countdown that launches a round. The game now runs itself. Next: Episode 2 builds the three maps that make every match different.

0
Total XP
1
Level
0
Best Streak
0%
Accuracy