I need only 10 members in a team in my game, how do i script that?
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.