---
name: setup-lobby
description: Create a lobby and round system for Roblox games
disable-model-invocation: true
allowed-tools: mcp__Roblox_Studio__run_code, mcp__Roblox_Studio__insert_model, AskUserQuestion
argument-hint: [optional: round type]
---

Set up a lobby/round system in the currently open Roblox Studio place.

## Step 1: Ask about the round system

Use AskUserQuestion:

**Question 1 — Game Mode** (multiSelect: false)
- `Free-for-all` — Every player for themselves
- `Teams` — Players split into teams
- `Rounds with elimination` — Last player/team standing wins
- `Objective-based` — Complete a task to win (capture flag, etc.)

**Question 2 — Lobby Features** (multiSelect: true)
- `Countdown timer` — Show timer before round starts
- `Minimum players` — Wait for enough players before starting
- `Map voting` — Players vote on which map to play
- `Ready-up system` — Players press a button when ready

**Question 3 — Round Flow** (multiSelect: false)
- `Lobby > Round > Results > Repeat (Recommended)` — Standard loop
- `Lobby > Team Select > Round > Results > Repeat` — With team picking phase
- `Continuous` — No lobby, players join mid-round
- `Tournament bracket` — Elimination rounds until a winner

**Question 4 — Rewards** (multiSelect: true)
- `Winner gets coins` — Currency reward for winning
- `XP for participating` — Everyone gets some XP
- `Kill rewards` — Coins/XP per kill
- `MVP display` — Show best player at end of round

Wait for answers before proceeding.

## Step 2: Create the round manager

Create a Script `RoundManager` in `ServerScriptService` that:
1. Manages the game state machine: `Waiting > Intermission > Active > Ended`
2. `Waiting`: waits for minimum players (if selected)
3. `Intermission`: countdown timer (configurable, default 15s), map vote if selected
4. `Active`: teleports players to the arena/map, starts the round, tracks objectives
5. `Ended`: determines winner, awards rewards, shows results, teleports back to lobby
6. Loops back to Waiting/Intermission
7. Fires RemoteEvents to update clients on state changes

## Step 3: Create the lobby

Using `mcp__Roblox_Studio__run_code`:
1. Create a lobby spawn area (SpawnLocation in a lobby zone)
2. Create an arena/map area (separate from lobby)
3. Create a status display (Part with SurfaceGui showing current state + timer)
4. If map voting: create a voting board with map options
5. If ready-up: create a ready button (Part with ClickDetector/ProximityPrompt)
6. If teams: create team selection area with colored pads

## Step 4: Create the client UI

Create a ScreenGui `RoundUI` in `StarterGui` with:
1. Top status bar showing: round state, timer, players alive
2. If teams: team scores display
3. Results screen overlay (winner name, stats, rewards earned)
4. If MVP: MVP card with player stats
5. LocalScript that listens to RemoteEvents and updates the UI

## Step 5: Create the teleport system

Create a ModuleScript `MapManager` in `ServerScriptService` that:
1. Stores spawn points for each map/arena
2. `teleportToArena(player)` — moves player to a random arena spawn
3. `teleportToLobby(player)` — moves player back to lobby
4. `teleportAllToArena(players)` — batch teleport
5. If teams: assigns team spawns

## Step 6: Verify

List all created scripts. Remind the user:
- Create actual map/arena geometry in Studio
- Adjust timer values in the RoundManager config section
- Test with multiple players (use local server test with 2+ players)
- Connect to DataStore system for persistent rewards
