You can see that my method immediately gets the thumbnail and also immediately changes the image
-- This code does the same thing as in the video
task.wait(5)
local ThumbnailStringTemplate = "rbxthumb://type=%s&id=%s&w=%s&h=%s"
local ThumbnailNames = {
[Enum.ThumbnailType.HeadShot] = "AvatarHeadShot",
[Enum.ThumbnailType.AvatarThumbnail] = "Avatar",
[Enum.ThumbnailType.AvatarBust] = "AvatarBust",
[Enum.ThumbnailSize.Size48x48] = "48",
[Enum.ThumbnailSize.Size60x60] = "60",
[Enum.ThumbnailSize.Size100x100] = "100",
[Enum.ThumbnailSize.Size150x150] = "150",
[Enum.ThumbnailSize.Size180x180] = "180",
[Enum.ThumbnailSize.Size352x352] = "352",
[Enum.ThumbnailSize.Size420x420] = "420",
}
local RandomUserIds = {4486178348, 845495652, 1460163254, 4049582782, 2772121961, 5277769812}
local ImageLabel1 = script.Parent.ImageLabel1
local ImageLabel2 = script.Parent.ImageLabel2
local function GetThumbnailByUserId(UserId: number, ThumbnailType: Enum.ThumbnailType, ThumbnailSize: Enum.ThumbnailSize): string
return ThumbnailStringTemplate:format(ThumbnailNames[ThumbnailType], tostring(UserId), ThumbnailNames[ThumbnailSize], ThumbnailNames[ThumbnailSize])
end
coroutine.wrap(function()
for i = 1,1000 do
local RandomuserId = RandomUserIds[math.random(#RandomUserIds)]
ImageLabel1.Image = GetThumbnailByUserId(RandomuserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end
print("My method ended")
end)()
coroutine.wrap(function()
for i = 1,1000 do
local RandomuserId = RandomUserIds[math.random(#RandomUserIds)]
ImageLabel2.Image = game.Players:GetUserThumbnailAsync(RandomuserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
end
print("Roblox method ended")
end)()
Players:GetUserThumbnailAsync() returns a string in the exact same format as your system does, except it also returns the isReady flag to tell you if the thumbnail is ready to use or not, i.e. if it will load.
Yours won’t always be ‘immediately ready’, the same way the one returned from Players:GetUserThumbnailAsync() won’t always be immediately ready.
Therefore, it does not have the capability for the same level of security as Players:GetUserThumbnailAsync(), hence why I said it’s good as a backup in case the API network request fails.
Based on your arbitrary benchmarks? So you are counting that the server will have no spikes/latency and it will always load the thumbnails immediately?
I don’t see the point in storing every thumbnail type and size when there aren’t many cases, maybe none, where the thumbnail needs to be changed or where a different one is used for each player. You usually always use the same type and size for everyone.
Maybe I’m wrong, but I think it’s not worth creating a module and storing all of these things when you could just use GetUserThumbnailAsync which does the exact same thing or directly put the link and change the user ID to the very few instances that show an user profile picture.