Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you take players then divide them in two groups?

This is what I have made so far.

if players == 2 or 4 or 6 or 8 or 10 then -- The proccess end

4 comments

0

This is not a request site. If you could, please put more effort into your script. Thank you.

0

I'm not requesting a script I'm asking for a method to divide players...

1

Use a for loop to loop through the players. Then, if the current index of the table is odd, place them on one team, but if the current index is even, place them on the other. This will evenly split the teams

0

Oh ok thx

1 answer

I wish you wouldn't be so broad with what you need but this script will suffice I hope. What you need to do is get all the players, with getplayers method on game.Players, then you need to take out half of them and put them somewhere else to access half of all players later on.

local players = game.Players:GetPlayers()
local halfPlayers = {}
local num = 1

while num <= #players / 2 do
wait()
num = num + 1
table.insert(halfPlayers,players[num])
end

--You can access half the players with the table 'halfPlayers'

This discussion is preserved as it was. New answers, comments, and votes are closed.