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

I need help with team balancing?

Asked by 10 years ago

what i want is only one player on the red team and all the other players will be at the blue team. and i dont know how to do it

if balanced then
                    local red = 1
                    team = math.random(1,2) > i edited it cause its wrong
                    if team == 1 then
                        red = red + 1
                        obj.TeamColor = BrickColor.new("Bright red")
                    elseif team == 2 then
                        blue = blue + 1
                        obj.TeamColor = BrickColor.new("Bright blue")
                    end

sorry if i did not explained it so well guys wat im actually doing is making teams (its a sword fighting game) and i only want Red team to have only limited players or 1 player

2 answers

Log in to vote
0
Answered by 10 years ago

Not sure what you are doing here, you are setting team to a random number between 30 and 45 then if team == 1 (impossible as it has to be 30-45) red will equal red + 1 (making it 2). Then you are saying if team is 2 (again impossible for the same reason as above) the variable blue will be made 1.

To do this you would need to use for loops in order to cycle through all players. http://wiki.roblox.com/index.php?title=Loops#For

players = game:GetService("Players"):GetPlayers()
for i,v in pairs(players) do
    if red ~= 2
        local red = 1
        team = math.random(1,2)
        if team = 1 then
            red = red +1 
        end
    else 
        blue = blue +1
    end
end

That's probably the closest you will get with the script you are using, although that still has issues.. That is not a finished script, just some adjustments to yours.

0
ow lol my bad i should have put math.random(1,2) Arnel050039 20 — 10y
0
theres something wrong with your script its says then is expected before local :| Arnel050039 20 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

For me, the teams even out automatically, assuming you have an even number of teams and the server limit matches that. For example: Team Red and Team Blue, ten server max, it should work automatically. (idk if that works when hundreds of people join at the same time, the most i ever had in my game was 50)

Answer this question