Like i am trying to make a camping game(by samsonxvi) so i need to make it choose a random player's https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username= different players also i want it to choose a random players name. SOMEBODY PLS HELP ME!!!
You can use :GetPlayers() to get a table of players and then use math.random(smallestNumber, biggestNumber) to pick a random player in that table.
# means number of items.
if you say print(#players)
you are printing out the number of players.
here's what the code would look like:
players = game.Players:GetPlayers() randomPlayer = players[math.random(1,#players)]
keep in mind, if you try running this in a script immediately like this, there won't be any players and you'll get the error: bad argument #2 to 'random' (interval is empty)
so make sure you're using the code above when there's actual players in game.