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

I need help making a limit to how many people can be on a team?

Asked by 4 years ago
Edited 4 years ago

i need help on making a limit on how many people can be on a team. im new to scripting and im wondering if anyone could put the code in for me so i can copy it.

i have two teams, one is labeled Murderer and one is named Innocent. i would like 1 person on each team and for it to be random on which one they get. please and thank you.

0
If there are teams in ur game, I'll be interested in playing ur game ^^ StarzSketchez 31 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I think this is what you're looking for let me know I'll try to help.

local team1playercount = game.ReplicatedStorage.numbervalue -- name of the numbervalue
local team2playercount = game.ReplicatedStorage.numbervalue -- name of the second numbervalue 
local teamlimit1 = 1 -- change the limit to whatever
local teamlimit2 = 1 -- change the limit to whatever
game.Players.PlayerAdded:Connect(function(player)
    local team = math.random(1,2)
    if team == 1 then
        if team1playercount.Value ~= teamlimit1 then
        team1playercount.Value = team1playercount.Value + 1
        player.TeamColor = BrickColor.new("Really red") -- change color to the first teamcolor 
        else
            if team2playercount.Value ~= teamlimit2 then
            team1playercount.Value = team1playercount.Value + 1
            player.TeamColor = BrickColor.new("Really red") -- change color to the second teamcolor
            else
                print("Both teams are full!")
            end
        end 
    elseif team == 2 then
        if team2playercount.Value ~= teamlimit2 then
        team1playercount.Value = team1playercount.Value + 1
        player.TeamColor = BrickColor.new("Really red") -- change color to the second teamcolor
        else
            if team1playercount.Value ~= teamlimit1 then
            team1playercount.Value = team1playercount.Value + 1
            player.TeamColor = BrickColor.new("Really red") -- change color to the first teamcolor 
            else
                print("Both teams are full!")
end
    end
end
    end)
Ad

Answer this question