Hey, I'm making a game which has three teams, Mortals, Mortal Heroes, and Gods. I want to make it so that the Gods team can only have one player on it at a time and so that when the God dies he becomes a mortal (joins the Mortals team.) The Mortals and Mortal Heroes teams should not have a team limit and when they die they should stay on the same team, I just want these rules to apply to the one player on the Gods team. The team colors are Lapis for the Gods, Really Red for the Mortal Heroes, and New Yeller for the Mortals, in case you need any of that information to make this work. Could anyone help me figure out how to do this? Thanks, and comment below or message me on Roblox if you have any questions or if you need any more information to answer this. Thanks, Skyraider5
COMMUNITY QUESTION
How Do I Make a Team Have a Limited Number Of Players?
1 answer
Highly recommend you don't copy and paste, however I did put it into context for you. If you have any questions please reply and I will help asap.
local teamz = {
['God'] = 1,
['Normal'] = 16
}
local teams = game:GetService('Teams')
local gods = Instance.new('Team', teams)
local normal = Instance.new('Team', teams)
gods.Name = 'God'
gods.TeamColor = BrickColor.new('Bright Red')
normal.Name = 'Normal'
local function getamount(str)
local amount = 0
for k,v in next, game:GetService('Players'):GetPlayers()do
if v.Team == teams[str] then
amount = amount + 1
end
end
return amount
end
game:GetService('Players').PlayerAdded:connect(function(p)
p.Team = normal
local lteam = p.Team
p:GetPropertyChangedSignal('Team'):connect(function()
table.foreach(teamz, function(a,b)
print(p.Team == teams[a], getamount(a) - 1 < b)
if p.Team == teams[a] and getamount(a) - 1 < b then
print'you can change teams!'
return
elseif p.Team == teams[a] then
print'sorry, this team is full!'
p.Team = lteam
end
end)
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
No, it's just the team limiter.
This wasn't the actual answer, it might work, but it doesn't with the way my game is set up I guess, but anyway I did figure out how to do it so this is technically answered just this answer wasn't it