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

How to make two random teams?

Asked by 10 years ago

This is the map randomizer, and it loads the map, but, I want it to tp all the players to 2 different teams. Anyone know what to add??

while true do
    wait(30)--intermission
    maps = game.ServerStorage.Maps:GetChildren()
    map = maps[math.random(1, #maps)]
    map:Clone().Parent = game.Workspace
    blue = 0
    red = 0
    local teamplay = game.Players.GetChildren()
    for i = 1,game.Players.NumPlayers do
        local ran = math.random(1,game.Players.NumPlayers)
        if blue == red then -- if they are the same it is randomely generated
            br = math.random(1,2)
            if br == 1 then
                teamplay[ran].TeamColor = BrickColor.new("Bright blue")
            elseif br == 2 then
                teamplay[ran].TeamColor = BrickColor.new("Bright red")
            end
        elseif red >= blue then
            teamplay[ran].TeamColor = BrickColor.new("Bright red")
        elseif blue >= red then
            teamplay[ran].TeamColor = BrickColor.new("Bright blue")
        end
    end
    for _,player in pairs(game.Players:GetPlayers()) do
        if player.Character then
               spawns = map.Spawns:GetChildren()
         player.Character:MoveTo(spawns[math.random(1, #spawns)].Position)
       end
    end
    wait(300)-- five minutes
    for i,player in pairs(game.Players:GetPlayers()) do
        if player.Character then
            player.Character.Head:remove()
            player.TeamColor = BrickColor.new("White")
        end
    end
end

2 answers

Log in to vote
0
Answered by
Bzrk262 15
10 years ago

This Script automatically sorts the players into the teams so you don't have to. The script is perfectly fine so just add it to the game and it should work.

-- Overall: The Sorting Script Is Already There
0
I have tried, where should the spawns be and what should their names be?? NinjoOnline 1146 — 10y
0
And also, im not sure if its just me, but when I load it, my name is like glitched in between the teams, or is it a glitch NinjoOnline 1146 — 10y
0
ROBLOX tries to auto balance teams and you would need 2 players for it to work. Bzrk262 15 — 9y
Ad
Log in to vote
0
Answered by 10 years ago

the script is fine.put the spawns where u want and u don't need to name them just put a line to kill them after dividing teams this will automatically tp them to their spawns . when Ur name glitches on leader board it isn't a glitch it has happened to me several times in different games.

Answer this question