A Round-Based Game Loop
By the end of this page your game will run on a loop by itself: players wait in a lobby, get teleported into an arena when the timer hits zero, play a timed round, and get sent back to the lobby when somebody wins — then it all starts again.
Time: 40 to 60 minutes.
Cost: about six or seven messages. Build messages are charged by how much work each one takes rather than a flat rate, with a minimum of 0.1 credits per message — watch the credits pill in the dashboard header.
You need: Roblox Studio open on a place you can edit, and the Revix plugin connected — the pill at the top of the dashboard should show your game's name with a green dot. If it does not, start with Setup.
What you're building
A state machine that never stops. Intermission, round, results, intermission again. The hard part is not any single state, it is making sure the loop cannot get stuck: a player leaving mid-round, everybody dying at once, or a round ending while another one is starting are all ways a loop wedges itself and stops forever.
Done looks like this: you press Play, watch a countdown in the lobby, get teleported into the arena, watch a round timer count down, and end up back in the lobby with a winner announced — without ever touching anything.
Step 1 — Build the lobby and the arena
Build two areas 500 studs apart. First a lobby: a 100 x 100 stud platform with low walls, a SpawnLocation, and a big blank sign facing the spawn point. Second an arena: a 200 x 200 stud walled floor with four spawn pads in the corners, raised seating around the outside, and lighting that makes it feel different from the lobby. Anchor everything, put the lobby in a folder called Lobby and the arena in a folder called Arena, both in Workspace.What happens. Both areas get built as one job. Bigger builds take a while — you will see a step counter climbing and a checklist filling itself in while parts appear in the viewport.
Check it worked. Press Play. You should spawn in the lobby, not the arena, and the arena should be visible in the distance in Studio.
Step 2 — Write the loop
Write a round loop for my game on the server. Intermission of 20 seconds while players wait in the lobby, then a round of 90 seconds. At the start of a round, teleport every player in the lobby to a random arena spawn pad. At the end, send everyone back to the lobby, wait 5 seconds showing the result, then start intermission again. The loop must keep running forever with at least one player, and it must handle a player leaving mid-round without stalling. Put all the timings in a config module so I can change them in one place.What happens. The loop lands in ServerScriptService because only the server may decide what state a round is in. Timings go into a module in ReplicatedStorage so both the loop and any on-screen timer read the same numbers.
Check it worked. Press Play and wait. Twenty seconds in, you should be standing in the arena. Ninety seconds later, back in the lobby. If you never move, check the Output window and then send:
The round loop is not teleporting me. Read the output window, name the cause in one sentence, then make the smallest fix that gets the loop running.Step 3 — Show the state on screen
Add a HUD showing the round state: a bar across the top of the screen with the phase name on the left (WAITING, INTERMISSION, ROUND, RESULTS), a large countdown in the middle, and the number of players alive on the right. It updates live from the server, and it turns amber in the last 10 seconds of a round. Keep it small enough that it does not block gameplay.What happens. The screen goes into StarterGui together with the script that drives it. A HUD is one of the few screens built visible from the start — panels that open on demand are built switched off so they cannot flash on spawn.
Check it worked. Press Play. The bar should count down through intermission, switch to ROUND, and turn amber near the end.
Step 4 — Add a win condition
Add a win condition to the round: last player standing. A player who dies during a round is out and gets sent back to the lobby to spectate until the round ends. When one player is left, or when the round timer runs out, end the round immediately, announce the winner by name on everyone's screen for 5 seconds, and give the winner 1 Wins leaderstat point. Handle nobody surviving and everybody surviving.What happens. Elimination is checked on the server, so a player cannot tell the game they survived. The last sentence matters more than it looks: the two states that break most round games are zero survivors and a tie.
Check it worked. Press Play, let the round start, and kill yourself in the arena. You should end up back in the lobby and, because you were the only player, the round should end straight away rather than running its full ninety seconds.
Step 5 — Ask for the loop to be tested
Revix cannot press Play for you. There is no automation for that anywhere in the product. What it can do is two very useful things: write and run a real test inside your place, and read what your running game printed into the Output window afterwards.
Ask for the test first:
Write and run a test for the round loop. Check that the phase order is always intermission, round, results and back to intermission; that ending a round twice in a row does not start two rounds; that a round with zero players returns to waiting instead of stalling; and that the config timings are the ones actually used. Report each check separately.What happens. You get back a pass or fail list with each failing check named, and Revix fixes what failed rather than moving on. It is not allowed to declare a pass without running something.
Then do the live half yourself:
I am going to press Play and let three full rounds run. Tell me exactly what to watch for, then when I say go, read the output window and tell me whether the loop stalled or double-fired.Check it worked. Let three rounds cycle. Then send go and read what comes back. Revix will quote the errors and warnings it found and name which ones matter.
Step 6 — Handle the empty server
When there are no players, the loop should sit in a WAITING state instead of running rounds to an empty arena, and start intermission the moment the first player joins. If everyone leaves mid-round, end the round cleanly and go back to waiting. Then check the whole build for problems and fix everything you find.Check it worked. Press Play, let intermission start, then stop the playtest. Press Play again. It should begin from waiting and move into intermission, not resume half a round.
Make it yours
Add three arena maps in a folder and rotate to a random one each round, showing the map name during intermission.Split players into a red team and a blue team at the start of each round, auto balance the numbers, and turn off friendly fire.Add a vote screen during intermission where players pick the next map, showing live vote counts.Give players a random weapon from a table when a round starts and take it away when they return to the lobby.Add a shrinking safe zone that damages anyone outside it, starting 40 seconds into each round.If something goes wrong
The loop runs once then stops.
The round loop runs one round and then never starts again. Read the output window, find where the loop exits, name the cause in one sentence, then fix only that.Two rounds start at the same time.
Two rounds are starting on top of each other and the timer jumps around. Make the loop refuse to start a round while one is already running, and add a test that proves it.Players teleport into the floor or into each other.
Players spawn inside the arena floor when a round starts. Measure the arena spawn pads and move each teleport point 5 studs above its pad, spaced so two players never land in the same spot.The countdown on screen does not match the server.
The HUD countdown drifts away from the real round timer. Have the server send the phase end time once per phase and let the screen count down to it locally, instead of sending a number every second.The build stopped before it finished. A card reading "That one stopped early" appears with a Keep going button. Press it, or type continue. Nothing already built is undone.