I wan't to select a random player for the script to execute on. How would I do that?
✓ ANSWER ACCEPTED
Ho do you do math.random but with players? I want to select a random player for the script
1 answer
✓ Accepted answer
You can put all the players in a table, then do a math.random. Below is a simple script where it would print a random name every second.
while wait(1) do
local players = game.Players:GetPlayers() --getting the players
local person = math.random(1,#players) --getting a number from 1 to the amount of elements in the table
print(players[person]) --prints the element in that position
end
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
ys