GetUserThumbnailAsync() for every player?

This is probably a very simple question but I couldn’t find the answer anywhere here or while browsing. So I’m in the middle of creating a trading system for my game, and came across an issue. I have a script in ServerScriptService and I have a Template in ServerStorage for the avatar’s head-shot. I know how to use GetUserThumbnailAsync() but the way I’m doing it only works for the local player. I thought using #Players might help in a for loop but that didn’t work either. I have a grid setup for every avatar in game just need the thumbnail to clone for EVERY player, I’m probably missing an obvious step so any help is appreciated! Thanks in advanced,
Script (forgot it)

local template = game.ServerStorage:FindFirstChild("Template")
local headType = Enum.ThumbnailType.HeadShot
local headSize = Enum.ThumbnailSize.Size100x100
local Players = game:GetService("Players")
 for plr in pairs(#Players:GetChildren()) do
 local content, bool = Players:GetUserThumbnailAsync(plr.UserId, headType,headSize)
 local temp = template:Clone()
 temp.Parent = -- Can do myself
 temp.Name = -- Can do Myself
 temp.Image = content
end

-Notrealac0unt

I’m confused. Something I noticed right off the bat is that you’re getting the number of children in the players instead of just getting the children. # before Players:GetChildren() gets the Number of children instead.
Try doing Players:GetChildren() without the #.
(I also noticed you’re only doing plr instead of i, plr, which can be bad, since it’s gathering the number in the for loop. Try _, plr instead.)

2 Likes

Yes, feel like a complete moron. I looked at that then changed it to just :GetChildren() and changed just plr to i, plr after that it worked. Thanks!

1 Like