I wan't to select a random player for the script to execute on. How would I do that?
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.
1 | while wait( 1 ) do |
2 | local players = game.Players:GetPlayers() --getting the players |
3 | local person = math.random( 1 ,#players) --getting a number from 1 to the amount of elements in the table |
4 | print (players [ person ] ) --prints the element in that position |
5 | end |
Hope this helps!