Other way to get the thumbnail of a user

Your method isn’t really something new. Roblox also uses the same URL but with the added feature of it yielding the thread till the users image has loaded.

I got some results based off 10000 hits

Your method

Fastest Time: 0.0008523464202880859
0.000010967254638671875 Faster

Slowest Time: 0.05728936195373535
0.05725383758544922 Faster

Average Time: 0.0073143394470214845
0.00002934720516204782 Slower

GetUserThumbnailAsync

Fastest Time: 0.0008413791656494141
0.000010967254638671875 Slower

Slowest Time: 0.11454319953918457
0.05725383758544922 Slower

Average Time: 0.007343686652183532
0.00002934720516204782 Faster

Your Method
task.wait(3)

local avgTimes = {}
local userIdList = {4486178348, 845495652, 1460163254, 4049582782, 2772121961, 5277769812}

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 function GetThumbnailByUserId(UserId: number, ThumbnailType: Enum.ThumbnailType, ThumbnailSize: Enum.ThumbnailSize): string
	return ThumbnailStringTemplate:format(ThumbnailNames[ThumbnailType], tostring(UserId), ThumbnailNames[ThumbnailSize], ThumbnailNames[ThumbnailSize])
end	

for i = 1, 10000 do
	local startTime = tick()
	local selectedRandomID = userIdList[math.random(#userIdList)]
	script.Parent.Image = GetThumbnailByUserId(selectedRandomID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
	repeat task.wait() until script.Parent.IsLoaded == true
	avgTimes[i] = (tick() - startTime)
end

local fastestTime = math.huge
local slowestTime = 0
local totalTime = 0

for _, time in avgTimes do
	if time < fastestTime then
		fastestTime = time
	end
	if time > slowestTime then
		slowestTime = time
	end
	totalTime += time
end

local averageTime = totalTime / #avgTimes
warn(`-------- Image1 Results: --------`)
warn(`Fastest Time: {fastestTime}`)
warn(`Slowest Time: {slowestTime}`)
warn(`Average Time: {averageTime}`)
GetUserThumbnailAsync
task.wait(3)

local avgTimes = {}
local userIdList = {4486178348, 845495652, 1460163254, 4049582782, 2772121961, 5277769812}
local Players = game:GetService("Players")

for i = 1, 10000 do
	local startTime = tick()
	local selectedRandomID = userIdList[math.random(#userIdList)]
	script.Parent.Image = Players:GetUserThumbnailAsync(selectedRandomID, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
	repeat task.wait() until script.Parent.IsLoaded == true
	avgTimes[i] = (tick() - startTime)
end

local fastestTime = math.huge
local slowestTime = 0
local totalTime = 0

for _, time in avgTimes do
	if time < fastestTime then
		fastestTime = time
	end
	if time > slowestTime then
		slowestTime = time
	end
	totalTime += time
end

local averageTime = totalTime / #avgTimes
warn(`-------- Image2 Results: --------`)
warn(`Fastest Time: {fastestTime}`)
warn(`Slowest Time: {slowestTime}`)
warn(`Average Time: {averageTime}`)
1 Like

It’s because yours isn’t loading any images except the last one. Roblox’ method is waiting for the image to load, yours just skips to the next image id, not letting the others load