hi so im trying to make a script that randomly picks players in the server is there any way to make that happen?
1 Like
local Players = game.Players:GetPlayers()
local RandomNumber = math.random(#Players)
local PickedPlayer = Players[RandomNumber]
Is this what you’re looking for, or do you want it to get the icon of the player as well as stated in the topic of the post? If so, you can get the icon by doing the following:
local userId = PickedPlayer.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
-- At this point, set the content to the image of an imageLabel.
2 Likes
local randomPlayer = game.Players:GetPlayers()[math.Random(1, #game.Players:GetPlayers)]
will choose a random player
2 Likes