can you make me a tag system for roblox and to make the gui use billboard and once a player is tagged the tagger and runner both become taggers and also a players remaining gui feature and when everyone but 1 person is tagged the last runner/survivor gets a +1 win on their leaderstats also add a coins feature using gui and if you win as a runner you get 500 coins and as a tagger every person you tag you get 100 coins and make sure there is a round system where it teleports the players between the lobby and the maps and it will randomize the map and also make sure the runners and chasers have different spawns on the map
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Certainly! Below is a comprehensive guide to creating a tag system for Roblox, including GUI, leaderstats, coins, and a round system with map randomization and different spawns for runners and chasers.
Step 1: Setup Leaderstats and Coins
First, we need to set up Leaderstats and Coins for each player.
ServerScriptService:
Create a script named LeaderstatsScript.
lua
-- LeaderstatsScript in ServerScriptService
game.Players.PlayerAdded:Connect(function(player)
-- Create Leaderstats folder
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create Wins stat
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Value = 0
wins.Parent = leaderstats
-- Create Coins stat
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
end)
Step 2: Tag System
ServerScriptService:
Create a script named TagSystem.
lua
-- TagSystem in ServerScriptService
local runners = {}
local taggers = {}
local gameInProgress = false
local mapFolder = game.Workspace:FindFirstChild("Maps")
local lobby = game.Workspace:FindFirstChild("Lobby")
local roundTime = 120 -- Time for each round in seconds
local interRoundTime = 10 -- Time between rounds in seconds
-- Function to start a new round
local function startRound()
if not mapFolder or #mapFolder:GetChildren() == 0 then return end
gameInProgress = true
-- Randomize map
local maps = mapFolder:GetChildren()
local selectedMap = maps[math.random(1, #maps)]
game.Workspace.CurrentCamera.CameraSubject = nil
selectedMap:Clone().Parent = game.Workspace
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.CurrentCamera
-- Clear previous roles
runners = {}
taggers = {}
-- Teleport players to their spawns
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
if character then
local spawns = selectedMap:FindFirstChild("Spawns")
if spawns then
local runnerSpawns = spawns:FindFirstChild("RunnerSpawns")
local taggerSpawns = spawns:FindFirstChild("TaggerSpawns")
if #taggers == 0 and runnerSpawns and #runnerSpawns:GetChildren() > 0 then
-- First player is a runner
local spawn = runnerSpawns:GetChildren()[math.random(1,#runnerSpawns:GetChildren())]
character:SetPrimaryPartCFrame(spawn.CFrame)
table.insert(runners, player)
else
-- All other players are taggers
local spawn = taggerSpawns:GetChildren()[math.random(1,#taggerSpawns:GetChildren())]
character:SetPrimaryPartCFrame(spawn.CFrame)
table.insert(taggers, player)
end
else
character:SetPrimaryPartCFrame(lobby.CFrame)
end
end
end
-- Start round timer
wait(roundTime)
endRound()
end
-- Function to end the round
local function endRound()
gameInProgress = false
local survivors = #runners
-- Check if there is only one survivor
if survivors == 1 then
local survivor = runners[1]
local wins = survivor:FindFirstChild("leaderstats"):FindFirstChild("Wins")
wins.Value = wins.Value + 1
local coins = survivor:FindFirstChild("leaderstats"):FindFirstChild("Coins")
coins.Value = coins.Value + 500
end
-- Teleport players back to the lobby
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
if character then
character:SetPrimaryPartCFrame(lobby.CFrame)
end
end
-- Remove the current map
for _, map in pairs(game.Workspace:GetChildren()) do
if map:IsA("Model") and map ~= lobby then
map:Destroy()
end
end
-- Wait before starting the next round
wait(interRoundTime)
startRound()
end
-- Tag detection
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Touched:Connect(function(hit)
if gameInProgress then
local otherPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
if otherPlayer and not table.find(taggers, otherPlayer) then
-- Tag the player
table.insert(taggers, otherPlayer)
table.insert(runners, player) -- The tagger also becomes a runner
table.remove(runners, table.find(runners, otherPlayer))
local coins = player:FindFirstChild("leaderstats"):FindFirstChild("Coins")
coins.Value = coins.Value + 100
end
end
end)
end)
end)
-- Start the first round after a delay
wait(5)
startRound()
Step 3: GUI System
StarterGui:
Create a ScreenGui named TagGUI.
Inside TagGUI, add a TextLabel named RemainingPlayers and a TextLabel named Coins.
lua
-- TagGUI in StarterGui
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local remainingPlayersLabel = script.Parent:WaitForChild("RemainingPlayers")
local coinsLabel = script.Parent:WaitForChild("Coins")
-- Update coins
leaderstats.ChildAdded:Connect(function(child)
if child.Name == "Coins" then
coinsLabel.Text = "Coins: " .. child.Value
end
end)
leaderstats.ChildRemoved:Connect(function(child)
if child.Name == "Coins" then
coinsLabel.Text = "Coins: 0"
end
end)
leaderstats.ChildAdded:Connect(function(child)
if child.Name == "Coins" then
child:GetPropertyChangedSignal("Value"):Connect(function()
coinsLabel.Text = "Coins: " .. child.Value
end)
end
end)
-- Update remaining players
game.Players.PlayerAdded:Connect(function()
updateRemainingPlayers()
end)
game.Players.PlayerRemoving:Connect(function()
updateRemainingPlayers()
end)
-- Function to update the remaining players label
local function updateRemainingPlayers()
local runnersCount = #game.ServerScriptService.TagSystem:GetAttribute("runners")
remainingPlayersLabel.Text = "Remaining Runners: " .. runnersCount
end
-- Initial update
updateRemainingPlayers()
Step 4: Billboard GUI
StarterCharacterScripts:
Create a LocalScript named BillboardGUI.
lua
-- BillboardGUI in StarterCharacterScripts
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local leaderstats = player:WaitForChild("leaderstats")
local coinsValue = leaderstats:WaitForChild("Coins")
-- Create BillboardGui
local billboard = Instance.new("BillboardGui")
billboard.Adornee = character.Head
billboard.Size = UDim2.new(2, 0, 1, 0)
billboard.StudsOffset = Vector3.new(0, 3, 0)
billboard.Parent = character.Head
-- Create TextLabel for coins
local coinsLabel = Instance.new("TextLabel")
coinsLabel.Size = UDim2.new(1, 0, 0.5, 0)
coinsLabel.BackgroundTransparency = 1
coinsLabel.Text = "Coins: " .. coinsValue.Value
coinsLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
coinsLabel.TextScaled = true
coinsLabel.Parent = billboard
-- Update coins label
coinsValue:GetPropertyChangedSignal("Value"):Connect(function()
coinsLabel.Text = "Coins: " .. coinsValue.Value
end)
Step 5: Map and Spawn Setup
Workspace:
Create a folder named Maps.
Inside Maps, add your map models. Each map should have a folder named Spawns with two subfolders: RunnerSpawns and TaggerSpawns. Add Part objects as spawn points inside these subfolders.
Add a part named Lobby where players will wait between rounds.
Summary
LeaderstatsScript handles creating leaderstats for each player.
TagSystem manages the tagging mechanics, round system, and teleportation.
TagGUI displays the remaining runners and coins for the local player.
BillboardGUI shows the player's coins above their head.
Maps folder contains different maps with designated spawn points for runners and taggers.
This system should provide a fully functional tag game in Roblox with the requested features.