I'll help you create a complete round-based tag game system. This will involve several scripts working together. Let me break it down into organized modules:
1. Main Game Controller (ServerScriptService)
-- ServerScriptService/GameController
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local RunService = game:GetService("RunService")
-- Create necessary folders and remotes
local remotes = Instance.new("Folder")
remotes.Name = "Remotes"
remotes.Parent = ReplicatedStorage
local voteRemote = Instance.new("RemoteEvent")
voteRemote.Name = "VoteForMap"
voteRemote.Parent = remotes
local updateGuiRemote = Instance.new("RemoteEvent")
updateGuiRemote.Name = "UpdateGameStatus"
updateGuiRemote.Parent = remotes
-- Game Settings
local INTERMISSION_TIME = 20
local VOTING_TIME = 15
local ROUND_TIME = 180 -- 3 minutes
local MIN_PLAYERS = 2
local RUNNER_WIN_COINS = 500
local TAG_COINS = 100
-- Game State
local gameState = "Intermission"
local currentMap = nil
local taggers = {}
local runners = {}
local votes = {}
local roundTimer = 0
-- Get maps folder (create if doesn't exist)
local mapsFolder = ServerStorage:FindFirstChild("Maps") or Instance.new("Folder")
if not ServerStorage:FindFirstChild("Maps") then
mapsFolder.Name = "Maps"
mapsFolder.Parent = ServerStorage
end
-- Leaderstats Module
local function createLeaderstats(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Value = 0
wins.Parent = leaderstats
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
end
-- Billboard GUI Creation
local function createBillboardGui(character, text, color)
local head = character:WaitForChild("Head")
-- Remove existing billboard
local existingBillboard = head:FindFirstChild("RoleDisplay")
if existingBillboard then
existingBillboard:Destroy()
end
local billboardGui = Instance.new("BillboardGui")
billboardGui.Name = "RoleDisplay"
billboardGui.Size = UDim2.new(4, 0, 1, 0)
billboardGui.StudsOffset = Vector3.new(0, 2, 0)
billboardGui.AlwaysOnTop = true
billboardGui.Parent = head
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundTransparency = 1
textLabel.Text = text
textLabel.TextColor3 = color
textLabel.TextScaled = true
textLabel.Font = Enum.Font.SourceSansBold
textLabel.Parent = billboardGui
end
-- Update all clients with game status
local function updateAllClients(message)
updateGuiRemote:FireAllClients(message, roundTimer)
end
-- Get available maps
local function getMaps()
local maps = {}
for _, map in pairs(mapsFolder:GetChildren()) do
if map:IsA("Model") then
table.insert(maps, map.Name)
end
end
return maps
end
-- Handle voting
local function startVoting()
votes = {}
local maps = getMaps()
if #maps == 0 then
warn("No maps found in ServerStorage/Maps!")
return nil
end
-- Send voting options to all players
for _, player in pairs(Players:GetPlayers()) do
updateGuiRemote:FireClient(player, "Vote for a map!", VOTING_TIME, maps)
end
-- Wait for voting period
for i = VOTING_TIME, 0, -1 do
roundTimer = i
updateAllClients("Voting ends in: " .. i)
wait(1)
end
-- Count votes and select winner
local voteCounts = {}
for _, mapName in pairs(votes) do
voteCounts[mapName] = (voteCounts[mapName] or 0) + 1
end
local winningMap = nil
local highestVotes = 0
for mapName, count in pairs(voteCounts) do
if count > highestVotes then
winningMap = mapName
highestVotes = count
end
end
-- If no votes, pick random map
if not winningMap and #maps > 0 then
winningMap = maps[math.random(1, #maps)]
end
return winningMap
end
-- Load map
local function loadMap(mapName)
if currentMap then
currentMap:Destroy()
end
local mapTemplate = mapsFolder:FindFirstChild(mapName)
if mapTemplate then
currentMap = mapTemplate:Clone()
currentMap.Parent = workspace
return true
end
return false
end
-- Setup player as runner or tagger
local function setupPlayer(player, role)
local character = player.Character
if not character then return end
local humanoid = character:WaitForChild("Humanoid")
if role == "Tagger" then
table.insert(taggers, player)
createBillboardGui(character, "TAGGER", Color3.fromRGB(255, 0, 0))
-- Teleport to tagger spawn
local taggerSpawns = currentMap:FindFirstChild("TaggerSpawns")
if taggerSpawns then
local spawns = taggerSpawns:GetChildren()
if #spawns > 0 then
local spawn = spawns[math.random(1, #spawns)]
character:SetPrimaryPartCFrame(spawn.CFrame + Vector3.new(0, 5, 0))
end
end
else
table.insert(runners, player)
createBillboardGui(character, "RUNNER", Color3.fromRGB(0, 255, 0))
-- Teleport to runner spawn
local runnerSpawns = currentMap:FindFirstChild("RunnerSpawns")
if runnerSpawns then
local spawns = runnerSpawns:GetChildren()
if #spawns > 0 then
local spawn = spawns[math.random(1, #spawns)]
character:SetPrimaryPartCFrame(spawn.CFrame + Vector3.new(0, 5, 0))
end
end
end
end
-- Convert runner to tagger
local function convertToTagger(player)
-- Remove from runners
for i, runner in ipairs(runners) do
if runner == player then
table.remove(runners, i)
break
end
end
-- Add to taggers
table.insert(taggers, player)
-- Update billboard
if player.Character then
createBillboardGui(player.Character, "TAGGER", Color3.fromRGB(255, 0, 0))
end
end
-- Tag system
local function setupTagSystem()
for _, tagger in pairs(taggers) do
if tagger.Character then
local character = tagger.Character
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
character.HumanoidRootPart.Touched:Connect(function(hit)
if gameState ~= "InRound" then return end
local hitCharacter = hit.Parent
local hitHumanoid = hitCharacter:FindFirstChild("Humanoid")
if hitHumanoid then
local hitPlayer = Players:GetPlayerFromCharacter(hitCharacter)
-- Check if hit player is a runner
for _, runner in ipairs(runners) do
if runner == hitPlayer then
-- Give tagger coins
tagger.leaderstats.Coins.Value = tagger.leaderstats.Coins.Value + TAG_COINS
-- Convert runner to tagger
convertToTagger(hitPlayer)
-- Setup tag ability for new tagger
spawn(function()
wait(0.1)
setupTagSystem()
end)
break
end
end
end
end)
end
end
end
end
-- Start round
local function startRound()
gameState = "InRound"
taggers = {}
runners = {}
local players = Players:GetPlayers()
if #players < MIN_PLAYERS then
updateAllClients("Not enough players! Need at least " .. MIN_PLAYERS)
return false
end
-- Select random tagger
local taggerIndex = math.random(1, #players)
local originalTagger = players[taggerIndex]
-- Setup all players
for i, player in pairs(players) do
if player.Character then
if i == taggerIndex then
setupPlayer(player, "Tagger")
else
setupPlayer(player, "Runner")
end
end
end
-- Setup tag system
wait(1) -- Give time for spawning
setupTagSystem()
-- Round timer
for i = ROUND_TIME, 0, -1 do
if gameState ~= "InRound" then break end
roundTimer = i
updateAllClients("Round Time: " .. i .. " | Runners: " .. #runners .. " | Taggers: " .. #taggers)
-- Check win conditions
if #runners == 0 then
-- All runners caught - original tagger wins
if originalTagger and originalTagger.Parent then
originalTagger.leaderstats.Wins.Value = originalTagger.leaderstats.Wins.Value + 1
updateAllClients("All runners caught! " .. originalTagger.Name .. " wins!")
end
wait(3)
break
end
wait(1)
end
-- Round ended with survivors
if #runners > 0 then
updateAllClients("Runners survived! Runners win!")
for _, runner in pairs(runners) do
if runner.Parent then
runner.leaderstats.Wins.Value = runner.leaderstats.Wins.Value + 1
runner.leaderstats.Coins.Value = runner.leaderstats.Coins.Value + RUNNER_WIN_COINS
end
end
wait(3)
end
gameState = "Intermission"
return true
end
-- Main game loop
local function gameLoop()
while true do
-- Intermission
gameState = "Intermission"
-- Teleport everyone to lobby if exists
local lobby = workspace:FindFirstChild("Lobby")
if lobby then
local lobbySpawn = lobby:FindFirstChild("SpawnLocation") or lobby:FindFirstChild("Spawn")
if lobbySpawn then
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
player.Character:SetPrimaryPartCFrame(lobbySpawn.CFrame + Vector3.new(0, 5, 0))
end
end
end
end
for i = INTERMISSION_TIME, 0, -1 do
roundTimer = i
updateAllClients("Intermission: " .. i)
wait(1)
end
-- Check player count
if #Players:GetPlayers() < MIN_PLAYERS then
updateAllClients("Waiting for more players... (" .. #Players:GetPlayers() .. "/" .. MIN_PLAYERS .. ")")
wait(5)
continue
end
-- Voting phase
gameState = "Voting"
local selectedMap = startVoting()
if selectedMap then
updateAllClients("Loading map: " .. selectedMap)
if loadMap(selectedMap) then
wait(3)
startRound()
else
updateAllClients("Failed to load map!")
wait(3)
end
else
updateAllClients("No map selected!")
wait(3)
end
-- Clean up map
if currentMap then
currentMap:Destroy()
currentMap = nil
end
end
end
-- Handle vote submissions
voteRemote.OnServerEvent:Connect(function(player, mapName)
if gameState == "Voting" then
votes[player.Name] = mapName
end
end)
-- Player setup
Players.PlayerAdded:Connect(function(player)
createLeaderstats(player)
player.CharacterAdded:Connect(function(character)
-- Remove billboard on respawn during intermission
if gameState == "Intermission" then
wait(1)
local head = character:WaitForChild("Head", 5)
if head then
local billboard = head:FindFirstChild("RoleDisplay")
if billboard then
billboard:Destroy()
end
end
end
end)
end)
-- Start game loop
spawn(gameLoop)
2. Client GUI Handler (StarterPlayer > StarterPlayerScripts)
-- StarterPlayer/StarterPlayerScripts/ClientGameHandler
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- Get remotes
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local voteRemote = remotes:WaitForChild("VoteForMap")
local updateGuiRemote = remotes:WaitForChild("UpdateGameStatus")
-- Create main GUI
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "GameUI"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui
-- Status label
local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(0.4, 0, 0.1, 0)
statusLabel.Position = UDim2.new(0.3, 0, 0, 0)
statusLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
statusLabel.BackgroundTransparency = 0.3
statusLabel.Text = "Loading..."
statusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
statusLabel.TextScaled = true
statusLabel.Font = Enum.Font.SourceSansBold
statusLabel.Parent = screenGui
-- Voting frame
local votingFrame = Instance.new("Frame")
votingFrame.Size = UDim2.new(0.3, 0, 0.4, 0)
votingFrame.Position = UDim2.new(0.35, 0, 0.3, 0)
votingFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
votingFrame.Visible = false
votingFrame.Parent = screenGui
local votingTitle = Instance.new("TextLabel")
votingTitle.Size = UDim2.new(1, 0, 0.15, 0)
votingTitle.BackgroundTransparency = 1
votingTitle.Text = "Vote for a Map!"
votingTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
votingTitle.TextScaled = true
votingTitle.Font = Enum.Font.SourceSansBold
votingTitle.Parent = votingFrame
local votingList = Instance.new("ScrollingFrame")
votingList.Size = UDim2.new(0.9, 0, 0.8, 0)
votingList.Position = UDim2.new(0.05, 0, 0.15, 0)
votingList.BackgroundTransparency = 0.5
votingList.ScrollBarThickness = 8
votingList.Parent = votingFrame
-- Handle voting display
local function displayVotingOptions(maps)
-- Clear previous options
for _, child in pairs(votingList:GetChildren()) do
if child:IsA("TextButton") then
child:Destroy()
end
end
votingFrame.Visible = true
-- Create vote buttons
for i, mapName in ipairs(maps) do
local voteButton = Instance.new("TextButton")
voteButton.Size = UDim2.new(0.9, 0, 0, 50)
voteButton.Position = UDim2.new(0.05, 0, 0, (i-1) * 60)
voteButton.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
voteButton.Text = mapName
voteButton.TextColor3 = Color3.fromRGB(255, 255, 255)
voteButton.TextScaled = true
voteButton.Font = Enum.Font.SourceSans
voteButton.Parent = votingList
voteButton.MouseButton1Click:Connect(function()
voteRemote:FireServer(mapName)
votingFrame.Visible = false
end)
end
votingList.CanvasSize = UDim2.new(0, 0, 0, #maps * 60)
end
-- Update GUI
updateGuiRemote.OnClientEvent:Connect(function(message, timer, votingMaps)
statusLabel.Text = message
if votingMaps then
displayVotingOptions(votingMaps)
else
votingFrame.Visible = false
end
end)
3. Map Setup Guide
To set up your maps properly, create them in ServerStorage > Maps folder with this structure:
Maps (Folder in ServerStorage)
├── Map1 (Model)
│ ├── TaggerSpawns (Folder)
│ │ ├── Spawn1 (Part)
│ │ └── Spawn2 (Part)
│ ├── RunnerSpawns (Folder)
│ │ ├── Spawn1 (Part)
│ │ ├── Spawn2 (Part)
│ │ └── Spawn3 (Part)
│ └── [Your map parts/models]
└── Map2 (Model)
└── [Same structure]
4. Optional: Example Map Creator (ServerScriptService)
-- ServerScriptService/CreateExampleMap
local ServerStorage = game:GetService("ServerStorage")
-- Create Maps folder
local mapsFolder = ServerStorage:FindFirstChild("Maps") or Instance.new("Folder")
mapsFolder.Name = "Maps"
mapsFolder.Parent = ServerStorage
-- Create example map
local exampleMap = Instance.new("Model")
exampleMap.Name = "TestArena"
-- Create base
local base = Instance.new("Part")
base.Name = "Base"
base.Size = Vector3.new(100, 1, 100)
base.Position = Vector3.new(0, 0, 0)
base.Anchored = true
base.TopSurface = Enum.SurfaceType.Smooth
base.Material = Enum.Material.Grass
base.BrickColor = BrickColor.new("Bright green")
base.Parent = exampleMap
-- Create tagger spawns
local taggerSpawns = Instance.new("Folder")
taggerSpawns.Name = "TaggerSpawns"
taggerSpawns.Parent = exampleMap
local taggerSpawn = Instance.new("Part")
taggerSpawn.Name = "TaggerSpawn1"
taggerSpawn.Size = Vector3.new(4, 0.2, 4)
taggerSpawn.Position = Vector3.new(0, 0.5, 0)
taggerSpawn.Anchored = true
taggerSpawn.CanCollide = false
taggerSpawn.Transparency = 0.5
taggerSpawn.BrickColor = BrickColor.new("Really red")
taggerSpawn.Parent = taggerSpawns
-- Create runner spawns
local runnerSpawns = Instance.new("Folder")
runnerSpawns.Name = "RunnerSpawns"
runnerSpawns.Parent = exampleMap
for i = 1, 4 do
local runnerSpawn = Instance.new("Part")
runnerSpawn.Name = "RunnerSpawn" .. i
runnerSpawn.Size = Vector3.new(4, 0.2, 4)
runnerSpawn.Position = Vector3.new(
math.cos(math.rad(90 * i)) * 40,
0.5,
math.sin(math.rad(90 * i)) * 40
)
runnerSpawn.Anchored = true
runnerSpawn.CanCollide = false
runnerSpawn.Transparency = 0.5
runnerSpawn.BrickColor = BrickColor.new("Lime green")
runnerSpawn.Parent = runnerSpawns
end
-- Add some obstacles
for i = 1, 10 do
local wall = Instance.new("Part")
wall.Name = "Wall" .. i
wall.Size = Vector3.new(
math.random(5, 15),
math.random(5, 10),
math.random(2, 5)
)
wall.Position = Vector3.new(
math.random(-40, 40),
wall.Size.Y/2,
math.random(-40, 40)
)
wall.Anchored = true
wall.BrickColor = BrickColor.new("Medium stone grey")
wall.Parent = exampleMap
end
exampleMap.Parent = mapsFolder
print("Example map created in ServerStorage/Maps!")
This system includes:
- Complete round-based gameplay with intermission periods
- Map voting system with GUI
- Tag mechanics where tagged runners become taggers
- Different spawn locations for runners and taggers
- Billboard GUI showing player roles
- Leaderstat system tracking wins and coins
- Proper rewards (500 coins for surviving runners, 100 coins per tag)
- Minimum player requirements
- Automatic game loop
To use this system:
- Place the GameController script in ServerScriptService
- Place the ClientGameHandler in StarterPlayer > StarterPlayerScripts
- Create your maps following the structure shown above
- Optionally run the CreateExampleMap script once to generate a test map
- The game will automatically start when enough players join!