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

How to randomly select player?

p = game.Players:Children() player = p[math.random(1,#p)] This is some of the code I've tried, I've tried a few others, and can't figure out a way. I want to randomly select a player, and then display it to the player in a GUI.

2 answers

p = game.Players:GetChildren()
for i = 1,#p do
 player = math.random(1,p[i])
end

This shall work, though a bit unnecessary .

if this answered your question check mark :)

The Children method is deprecated. Use GetChildren.

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