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

Pick 6 random players out of a 16 Player Server?

So how would I go about picking 6 Random players every time a new round begins and to put the rest of the players in the other team?

Thank you for your help in advance :)

1 answer

✓ Accepted answer

Create a table containing all the players using GetChildren(). Then, choose a random player by indexing a random player from that table. Don't forget to remove the chosen players from the table, otherwise they can be chosen twice :

local Players = game.Players:GetChildren()

for i = 1, 6 do --Choose six players
ChosenPlayerIndex = math.random(#Players) --Chose a random player index
Players[ChosenPlayer].TeamColor = BrickColor.new("Bright blue") --Move the chosen player to the blue team
table.remove(Players, ChosenPlayerIndex) --Removes the player from the list so he can't be chosen again
end

(This script is supposed to be placed inside either game.Workspace or game.ServerScriptService, in a normal script)

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