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
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)
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
I threw together a really quick test, and from what I found the script should work (odd)
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)