Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a max limit on a team?

Asked by 10 years ago

I need only 10 members in a team in my game, how do i script that?

1 answer

Log in to vote
0
Answered by
Kratos232 105
10 years ago

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
0
When i used the script it made a whole new team? masterhalo55 75 — 10y
0
Did you change the team colors? Kratos232 105 — 10y
0
No...... masterhalo55 75 — 10y
0
Well I said to make the team colors your team colors. And it's kinda impossible for this script to make new teams. Kratos232 105 — 10y
0
my teams where the sasme colorse asd the escript but whej i spawned it had 3 teams red blue neutral. masterhalo55 75 — 10y
Ad

Answer this question