I am creating a game i have to put 3 players in one team and in the other 4 and in other 6 any ideas? [Btw i am new at scripting]
Well lets do this, We will create a loop that will run for every player and add them to a team
Assuming you have a max number of 13 players,
--variables local team1 = game.Teams.Team1 local team2 = game.Teams.Team2 local team3 = game.Teams.Team3 --shuffle local players=game.Players:GetChildren() local new = {} for i = #players, 1, -1 do local x = math.random(1, i) table.insert(new, players[x]) table.remove(players, x) end players = new --set for i,v in pairs(players) do if i<=3 then v.Team=team1 elseif i>3 and i<=7 then v.Team=team2 elseif i>7 and i<=13 then v.Team=team3 end end
Make sure to change team, team2, and team3 to the teams in your game.
Hope this helped if you have any questions please ask me :D