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

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

Asked by 9 years ago

This is what I have made so far.

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

0
This is not a request site. If you could, please put more effort into your script. Thank you. M39a9am3R 3210 — 9y
0
I'm not requesting a script I'm asking for a method to divide players... handsomebob10 0 — 9y
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 Perci1 4988 — 9y
0
Oh ok thx handsomebob10 0 — 9y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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'
Ad

Answer this question