So I’m trying to figure out How to make a TeamValue or MaxPlayer amount for my Four Teams. TeamChanger so when that team is full you are trying to choose it won’t let you pick that team. And it will say this team is full. But I can’t seem to figure it out. I’m not a good scripter this is my first time scripting something.
Like example
JailBreak when you try to choose the police team and it’s full it won’t let you choose it
4 Likes
The logic for this is relatively simple. You’ll just need to iterate through all the players in the game, and create variables that’s the sum of members for each team. Below is a function you can call that’ll do just that. You pass in the team you want to get the sum of as a parameter, then it returns how many players are currently on that team.
local function Get_Players_On_Team(team_name)
local sum = 0
for i, player in pairs(game.Players:GetPlayers()) do
if player.Team and player.Team.Name == team_name then
sum = sum + 1
end
end
return sum
end
Should work. From there, you can implement this to work with your team chooser buttons and you should be good to go 
2 Likes
You could do that, or avoid reinventing the wheel by using the function Teams gives you that allows you to get what players are on a team. Use the length operator to see how many are on the team.
print(#game:GetService("Teams")[team_name]:GetPlayers())
4 Likes