GetUserThumbnailAsync only fetches my own avatar

I’m making a custom leaderboard. And in it I want everybody’s player avatar, so I go to this function. Keep in mind the leaderboard is all client side, so this function (GetUserThumbnailAsync) is also ran client side.

Now it fetches the icon that’s fine, but for every other player, it shows my avatar again, when clearly a different userId has been inserted. Could this be a bug or am I missing something?

Screenshot

image

Code
local RepStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')

local template = RepStorage.GUI.PlayerFrame
local list = script.Parent

local function insertFrame(player)
	local content, isReady = Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size100x100)

	local new = template:Clone()
	new.Icon.Image = content
	new.Name = player.Name
	new.MainContainer.Username.Text = player.Name
	new.Parent = list
end

local function addPlayer(plr)
	
	if not list:FindFirstChild(plr.Name) then
		insertFrame(plr)
	end
	
end

local function removePlayer(plr)
	
	if list:FindFirstChild(plr.Name) then
		list:FindFirstChild(plr.Name):Destroy()
	end
end

for _, player in ipairs(Players:GetPlayers()) do

	insertFrame(player)

end

Players.PlayerAdded:Connect(addPlayer)
Players.PlayerRemoving:Connect(removePlayer)

Is this in a local script or a script? If it is a local script, it is everything to do with YOUR player, so player.Name will always be you.

Okay you didnt read none of what Ive written haha

1 Like

May you explain it in more detail, please?

All of it is up there. The problem im facing is that the Thumbnail function, no matter the different UserId’s that I’ve put, it always fetches my avatar. And yes its local, but i’d hope it would work locally too so i dont need to make a server workaround but if i have to so be it.

See my first screenshot. Different names (different players), yet two of my own avatars

If it’s on the client side, I have no idea how to help you other than make it serversided.

Apologies, hope you find a solution soon!

1 Like

I threw together a really quick test, and from what I found the script should work (odd)

image

Maybe make sure that there is no other scripts affecting the image
Another problem is that the “icon” image could be hidden under another imagelabel which shows the image of your avatar.

Code I used (pretty much the same)
local RepStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')

local template = RepStorage.Template
local list = script.Parent.Frame

local function insertFrame(player)
	local content, isReady = Players:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size100x100)

	local new = template:Clone()
	new.Icon.Image = content
	new.Name = player.Name
	--new.MainContainer.Username.Text = player.Name
	new.Parent = list
end

local function addPlayer(plr)

	if not list:FindFirstChild(plr.Name) then
		insertFrame(plr)
	end

end

local function removePlayer(plr)

	if list:FindFirstChild(plr.Name) then
		list:FindFirstChild(plr.Name):Destroy()
	end
end

for _, player in ipairs(Players:GetPlayers()) do

	insertFrame(player)

end

Players.PlayerAdded:Connect(addPlayer)
Players.PlayerRemoving:Connect(removePlayer)

See, you reminded me that i had an extra script in the template to change the icon as a test… works now haha, it be like that.

1 Like