local game = game:GetService("Players")
local ImageLabel = script.Parent
function setPlayerIcon(PlayerName)
local Success, Err = pcall(function()
local PlayerId = PlayerService:GetUserIdFromNameAsync(PlayerName)
local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size180x180
local Content, IsReady = PlayerService:GetUserThumbnailAsync(PlayerId, ThumbType, ThumbSize)
ImageLabel.Image = Content
end)
end
setPlayerIcon(game.Name)
So, my script doesn't show each player in the game's photo on the gui(Like a photo of the avatar)
I want it to show their picture for each player.
since you did
game = game:GetService("Players")
then you did
setPlayerIcon(game.Name)
aren’t you sending a variable for game.Players instead of Player Names?
I am not sure how to get their names, do I make a table or something?
yes
local players = game.Players:GetPlayers()
function setPlayerIcon(Players)
local Success, Err = pcall(function()
for i,v in pairs(Players) do-- loops through all players till they are all registered
local PlayerId = PlayerService:GetUserIdFromNameAsync(v.Name)--gets their name
local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size180x180
local Content, IsReady = PlayerService:GetUserThumbnailAsync(PlayerId, ThumbType, ThumbSize)
ImageLabel.Image = Content
end
end)
end
setPlayerIcon(players)
Works splendid, thanks a bunch!