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

How to randomly select player?

Asked by 10 years ago

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

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago
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 :)

Ad
Log in to vote
-1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

The Children method is deprecated. Use GetChildren.

Answer this question