Hello There!
I am making a team based game where Robloxians stop Administrators from destroying an iconic ‘O’. The issue is that I want it so that when an Administrator team player spawns, they will randomly be given a random role, kinda like Left 4 Survival system where if you die as a zombie you can either purchase a variant of the basic zombie or have RNG chose for you.
--//Services\\--
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
--//Configurations\\--
local RoundTimer = 30 --The amount of time a round last, on default, it's on 2.5 minutes.
local IntermissionTimer = 12 --The amount of time intermission last, on default, it's in 28 seconds.
local MinimumPlayerCount = 3 --This is used to detect if there isn't enough peopel to start the game.
local Status = "Intermission" --Two statuses, Intermission and Round. Used to see if a round is in progress or people waiting if a new player joins during a round.
--Teams
local RED = 0
local YELLOW_Notblufromtf2hehehehe = 0
local Spawnpoint = game.Workspace:WaitForChild("SpawnLocation")
local Statue = game.Workspace:WaitForChild("STATUE")
--//WeaponsFolder\\--
local WEAPONSFOLDER = game:GetService("ReplicatedStorage"):WaitForChild("WEAPONS")
--SubFolders
local BanHammersFolder = WEAPONSFOLDER:WaitForChild("AdministratorBanHammers")
--//Connections\\--
Players.PlayerAdded:Connect(function(Player)
if Status == "Round" then
if RED <= YELLOW_Notblufromtf2hehehehe then
Player.Team = Teams.Administrators
Player.TeamColor = Teams.Administrators.TeamColor
RED += 1
elseif YELLOW_Notblufromtf2hehehehe <= RED then
Player.Team = Teams.Robloxians
Player.TeamColor = Teams.Robloxians.TeamColor
YELLOW_Notblufromtf2hehehehe += 1
end
end
task.wait(1)
Player:LoadCharacter()
end)
while true do
RED = 0
YELLOW_Notblufromtf2hehehehe = 0
Statue:WaitForChild("Humanoid").Health = Statue.Humanoid.MaxHealth
for _, Player in pairs(Players:GetChildren()) do
Player.Team = Teams.Lobby
Player.TeamColor = Teams.Lobby.TeamColor
end
for _, Player in pairs(Players:GetChildren()) do
Player:LoadCharacter()
end
Status = "Intermission"
for i=IntermissionTimer, 1, -1 do
game.ReplicatedStorage:WaitForChild("UpdateTimer"):FireAllClients(i)
task.wait(1)
end
if #Players:GetChildren() == MinimumPlayerCount then
warn("Hey buddy, you lookin' lonely. Too bad I am just Warning. Wait for a stranger, or try inviting friends.")
task.wait(5)
else
Status = "Round"
for _, Player in pairs(Players:GetChildren()) do
if RED <= YELLOW_Notblufromtf2hehehehe then
Player.Team = Teams.Administrators
Player.TeamColor = Teams.Administrators.TeamColor
RED += 1
elseif YELLOW_Notblufromtf2hehehehe <= RED then
Player.Team = Teams.Robloxians
Player.TeamColor = Teams.Robloxians.TeamColor
YELLOW_Notblufromtf2hehehehe += 1
end
end
Spawnpoint.Neutral = false
task.wait(1)
for _, Player in pairs(Players:GetChildren()) do
Player:LoadCharacter()
end
for i=RoundTimer, 1, -1 do
if Statue:WaitForChild("Humanoid").Health <= 1 then
print("ADMINISTRATORS WON BECAUSE THEY ARE ADMINS LIKE THEY ARE POWERFUL LOL")
break
end
task.wait(1)
end
if Statue:WaitForChild("Humanoid").Health >= 1 then
print("Bro... Robloxians won, how the hell did you lose? Well, I mean Balancing Laws but bro, you have Raiggers, why not use him?!")
end
Spawnpoint.Neutral = true
task.wait(3)
end
end