✓ Accepted answer
Well first, you have to know some basic things about tables.
In a table, you can take the table's name followed by brackets and a number, and that gives you the value from the table corresponding to the number, like this:
MyTable = {"Hi","People","I'm","Perci1!"}
print(MyTable[1])
print(MyTable[3])
Since you can get a value from a table with a number, if we get a random number it should give us a random value. For this we use math.random().
MyTable = {"Hi","People","I'm","Perci1!"}
randomNumber = math.random(1,#MyTable)
randomValue = MyTable[randomNumber]
print[randomValue]
Now, we will talk about GetPlayers(). GetPlayers()converts all the player in the server into a table. Therefore we use the same method to get a random player as we used to get a random value.
players = game.Players:GetPlayers()
randomNumber = math.random(1,#players)
randomValue = players[randomNumber]
print(randomValue]
Hope i helped!
1 comment
Wow this really did help,I really like when people actualy help me unstead of give me just a script.