I need only 10 members in a team in my game, how do i script that?
COMMUNITY QUESTION
How do i make a max limit on a team?
1 answer
Hi. I guess if you only need 10 members in a team you could do something like this...
TeamColor1 = "Really red"
TeamColor2 = "Really blue"
Players = Game:GetService("Players")
function CheckTeam(Color)
local GetPlr = Players:GetPlayers()
local PlayerTable = {}
for x = 1, #GetPlr do
if GetPlr[x].TeamColor == Color then
table.insert(PlayerTable, GetPlr[x])
end
end
return #PlayerTable
end
function PlayerJoin(Player)
TeamNumber = CheckTeam(TeamColor1)
if TeamNumber < 10 then
Player.TeamColor = BrickColor.new(TeamColor1)
else
Player.TeamColor = BrickColor.new(TeamColor2)
end
end
Players.PlayerAdded:connect(PlayerJoin)
It's pretty simple really. What it does is, whenever someone joins in scans players for people in a team, then returns a number. It then checks the number to see if it's smaller then 10. If it is, it puts that person into the team, or it puts it onto another team. Since you didn't say the team colors you wanted you'll have to change it. You can edit it all you want. Oh, and there are easier ways to do this, but I felt lazy so I just made this...
Well, enjoy the script.
- Kratos232
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
When i used the script it made a whole new team?
Did you change the team colors?
No......
Well I said to make the team colors your team colors. And it's kinda impossible for this script to make new teams.
my teams where the sasme colorse asd the escript but whej i spawned it had 3 teams red blue neutral.