the round system isnt working
- User
the round system isnt working
Assistant
Let's fix the round system step by step. The most common issues with the round system not working are:
- Missing or misnamed objects (Lobby, Maps folder, spawn points).
- Scripts not running (disabled or misplaced).
- Character loading issues (Touched events not firing).
- Game state not updating (gameInProgress not being set correctly).
Here's a simplified, debug-friendly version of the
GameManagerscript that will help us identify where the problem is:Step 1: Verify Your Setup
Before running the script, ensure:
-
Workspace has:
- A
Partnamed Lobby (anchored,CanCollide= false). - A folder named Maps with at least one map model inside.
- Each map must have:
- A folder named Spawns.
- Inside Spawns, two folders: RunnerSpawns and TaggerSpawns, each with at least one
Part(anchored).
- Each map must have:
- A
-
ReplicatedStorage has:
- An
IntValuenamed RunnersRemaining. - A
StringValuenamed GameStatus.
- An
-
ServerScriptService has:
LeaderstatsScript(from earlier).GameManager(the script below).
-
StarterGui has:
TagGUIwith the GUI elements andGUIManagerLocalScript.
-
StarterCharacterScripts has:
BillboardHandlerLocalScript.
Step 2: Updated
GameManagerScript (Debug Version)Replace your existing
GameManagerscript with this:-- ServerScriptService > GameManager (Debug Version) local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Workspace = game:GetService("Workspace") -- Configuration local INTERMISSION_TIME = 15 -- Seconds for intermission local ROUND_TIME = 60 -- Reduced for testing (60 seconds) local MIN_PLAYERS = 1 -- Set to 1 for solo testing -- References local RunnersRemaining = ReplicatedStorage:WaitForChild("RunnersRemaining") local GameStatus = ReplicatedStorage:WaitForChild("GameStatus") local Lobby = Workspace:WaitForChild("Lobby") -- Ensure this exists local Maps = Workspace:FindFirstChild("Maps") -- Ensure this folder exists -- Game State local gameInProgress = false local runners = {} -- Table of runner players local taggers = {} -- Table of tagger players -- Debug function to print game state local function debugPrint() print("=== GAME STATE ===") print("Game in progress: " .. tostring(gameInProgress)) print("Runners: " .. #runners) print("Taggers: " .. #taggers) print("Players in game: " .. #Players:GetPlayers()) print("==================") end -- Function to teleport player to lobby local function teleportToLobby(player) local character = player.Character or player.CharacterAdded:Wait() if character and character:FindFirstChild("HumanoidRootPart") then character:SetPrimaryPartCFrame(Lobby.CFrame + Vector3.new(0, 3, 0)) print("Teleported " .. player.Name .. " to lobby") else warn("Failed to teleport " .. player.Name .. " (no character or HumanoidRootPart)") end end -- Function to start a new round local function startRound() print("Starting a new round...") -- Check if maps exist if not Maps or #Maps:GetChildren() == 0 then warn("No maps found in Workspace.Maps!") GameStatus.Value = "Error: No maps available" return end -- Select a random map local maps = Maps:GetChildren() local selectedMap = maps[math.random(1, #maps)]:Clone() selectedMap.Name = "CurrentMap" selectedMap.Parent = Workspace print("Loaded map: " .. selectedMap.Name) -- Get spawn points local spawns = selectedMap:FindFirstChild("Spawns") if not spawns then warn("Map missing Spawns folder!") selectedMap:Destroy() return end local runnerSpawns = spawns:FindFirstChild("RunnerSpawns") local taggerSpawns = spawns:FindFirstChild("TaggerSpawns") if not runnerSpawns or not taggerSpawns then warn("Map missing spawn points!") selectedMap:Destroy() return end -- Assign roles (randomly select one tagger, rest are runners) local players = Players:GetPlayers() if #players < MIN_PLAYERS then warn("Not enough players to start round") GameStatus.Value = "Waiting for more players..." return end -- Reset roles runners = {} taggers = {} -- Pick a random initial tagger local initialTagger = players[math.random(1, #players)] taggers[initialTagger] = true print(initialTagger.Name .. " is the initial tagger") -- Assign all other players as runners for _, player in ipairs(players) do if player ~= initialTagger then runners[player] = true end end -- Teleport players to their spawns for player, _ in pairs(runners) do local character = player.Character or player.CharacterAdded:Wait() local spawnPoint = runnerSpawns:GetChildren()[math.random(1, #runnerSpawns:GetChildren())] character:SetPrimaryPartCFrame(spawnPoint.CFrame + Vector3.new(0, 3, 0)) print("Teleported " .. player.Name .. " to runner spawn") end for player, _ in pairs(taggers) do local character = player.Character or player.CharacterAdded:Wait() local spawnPoint = taggerSpawns:GetChildren()[math.random(1, #taggerSpawns:GetChildren())] character:SetPrimaryPartCFrame(spawnPoint.CFrame + Vector3.new(0, 3, 0)) print("Teleported " .. player.Name .. " to tagger spawn") end -- Start the round gameInProgress = true RunnersRemaining.Value = #runners GameStatus.Value = "Round started! Time left: " .. ROUND_TIME print("Round started with " .. #runners .. " runners and " .. #taggers .. " taggers") -- Round timer for i = ROUND_TIME, 0, -1 do GameStatus.Value = "Time left: " .. i wait(1) -- Check if all runners are tagged if #runners <= 1 then GameStatus.Value = "Taggers win! (Only 1 runner left)" endRound() return end end -- Round ended normally (timer ran out) GameStatus.Value = "Round ended! All runners win!" endRound() end -- Function to end the current round local function endRound() print("Ending round...") -- Remove current map local currentMap = Workspace:FindFirstChild("CurrentMap") if currentMap then currentMap:Destroy() end -- Award wins to all remaining runners local survivors = {} for player, _ in pairs(runners) do table.insert(survivors, player) end if #survivors >= 1 then for _, survivor in ipairs(survivors) do local leaderstats = survivor:FindFirstChild("leaderstats") if leaderstats then leaderstats.Wins.Value = leaderstats.Wins.Value + 1 leaderstats.Coins.Value = leaderstats.Coins.Value + 500 print(survivor.Name .. " wins! +1 win and +500 coins") end end end -- Reset roles and teleport to lobby runners = {} taggers = {} for _, player in ipairs(Players:GetPlayers()) do teleportToLobby(player) end -- Update game state gameInProgress = false RunnersRemaining.Value = 0 GameStatus.Value = "Intermission" print("Round ended. Teleported all players to lobby") end -- Main game loop while true do -- Intermission phase print("Starting intermission...") for i = INTERMISSION_TIME, 0, -1 do GameStatus.Value = "Intermission: " .. i wait(1) end -- Check for enough players if #Players:GetPlayers() >= MIN_PLAYERS then startRound() else GameStatus.Value = "Waiting for more players..." wait(5) end end
Step 3: Debugging Steps
-
Check the Output Window for messages like:
- "Starting a new round..."
- "Teleported [Player] to [spawn]"
- "Round started with X runners and Y taggers"
- "Ending round..."
-
If rounds don't start:
- Look for errors like "No maps found" or "Not enough players."
- Ensure
MIN_PLAYERSis set to 1 for solo testing.
-
If players don't teleport:
- Check if the
Lobbypart exists in Workspace. - Verify that
Lobbyis anchored and hasCanCollideset to false.
- Check if the
-
If the round timer doesn't work:
- Check if
gameInProgressis being set totrueinstartRound(). - Ensure the
while true doloop in the main game loop is running.
- Check if
-
If the GUI doesn't update:
- Verify that
RunnersRemainingandGameStatusare being updated in the server script. - Check that the
GUIManagerLocalScript is running and connected to these values.
- Verify that
Step 4: Common Fixes
-
If the script doesn't run at all:
- Ensure the script is enabled (right-click the script in Explorer and check "Enabled").
- Make sure it's in ServerScriptService (not StarterPlayerScripts or elsewhere).
-
If players don't spawn correctly:
- Ensure all spawn parts in
RunnerSpawnsandTaggerSpawnsare anchored. - Check that the spawn parts are positioned correctly (not underground or in walls).
- Ensure all spawn parts in
-
If the round ends immediately:
- Check if
RunnersRemainingis being updated correctly. - Ensure the
Touchedevent is working (we'll add this in a later step).
- Check if
Next Steps
If the round system still isn't working after this, please:
- Share any error messages from the Output window.
- Confirm that all required objects (Lobby, Maps, spawn points) exist.
- Let me know what happens when you run the game (e.g., "Players don't move," "No rounds start," etc.).
We'll keep troubleshooting until it works! 🚀
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.