Making GetUserThumbnailAsync decal scale to fit the whole part

local Players = game:GetService("Players")

local content

local PLACEHOLDER_IMAGE = "rbxassetid://1574674476" -- replace with placeholder image

local eotdPhoto

local validEotd = false
local timeout = 5
local elapsed = 0
while not validEotd and elapsed < timeout do
	if shared.eotd == 0 or shared.eotd == 1 or shared.eotd == 2 then
		validEotd = true
		break
	end
	task.wait(0.2)
	elapsed = elapsed + 0.2
end

if not validEotd then
	warn("EOTD Displayer: shared.eotd is not set or invalid after waiting.")
	content = PLACEHOLDER_IMAGE
	eotdPhoto = "Elliot"
else
	-- fetch the thumbnail
	local thumbType = Enum.ThumbnailType.AvatarThumbnail
	local thumbSize = Enum.ThumbnailSize.Size420x420
	if shared.eotd == 0 then
		content = Players:GetUserThumbnailAsync(862478431, thumbType, thumbSize)
		eotdPhoto = Players:GetNameFromUserIdAsync(862478431)
		print("Employee of the day is Noxturnum2")
	elseif shared.eotd == 1 then
		content = Players:GetUserThumbnailAsync(273362069, thumbType, thumbSize)
		eotdPhoto = Players:GetNameFromUserIdAsync(273362069)
		print("Employee of the day is VoidLord0")
	elseif shared.eotd == 2 then
		content = Players:GetUserThumbnailAsync(shared.selectedPlayer, thumbType, thumbSize)
		eotdPhoto = Players:GetNameFromUserIdAsync(shared.selectedPlayer)
		print("Employee of the day is a random player.")
	end
end

-- set the Decal's content to the user thumbnail
local imageLabel = script.Parent:FindFirstChild("Picture")
if imageLabel then
	local decal = imageLabel:FindFirstChild("Decal")
	if decal then
		decal.Texture = content or PLACEHOLDER_IMAGE
	else
		warn("EOTD Displayer: Decal not found in Picture part.")
	end
else
	warn("EOTD Displayer: Picture part not found.")
end

local namePart = script.Parent:FindFirstChild("Name")
if namePart then
	local surfaceGui = namePart:FindFirstChild("SurfaceGui")
	if surfaceGui then
		local textLabel = surfaceGui:FindFirstChild("TextLabel")
		if textLabel then
			textLabel.Text = shared.selectedPlayerName or "Elliot"
		else
			warn("EOTD Displayer: TextLabel not found in SurfaceGui.")
		end
	else
		warn("EOTD Displayer: SurfaceGui not found in Name part.")
	end
else
	warn("EOTD Displayer: Name part not found.")
end

(when playing)
(when viewed in studio)

I need any texture returned by GetUserThumbnailAsync to expand to fill the whole face of the part as seen in studio with the default image, but as you can see it’s way too small right now.


Also for some reason, when the EOTD chosen is me (Noxturnum2) the thumbnail is skewed to the right?

And just for good measure I’ll show how it looks when the eotd is a random player (it’s supposed to be a random person in the server, but maybe GetPlayers() works weirdly when playtesting in studio? I’ll send the code just in case im wrong (this is in serverscriptservice)

shared.eotd = math.random(0,2)
shared.selectedPlayer = 1
if shared.eotd == 2 then
    local Players = game:GetService("Players")
    local playerList = Players:GetPlayers()
    if #playerList > 0 then
        local randomIndex = math.random(1, #playerList)
		shared.selectedPlayer = playerList[randomIndex].UserId
		shared.selectedPlayerName = playerList[randomIndex].Name
		print("Random selected user is "..shared.selectedPlayerName)
	else warn("Player list was empty; no user selected. Defaulting to user id 1")
	end
end

I believe this is just how the thumbnails are generated.

E.g. In your example where your avatar has been skewed to the right, I’m pretty sure this is because your avatar is holding a gear.

1 Like

Is there truly no way to make the thumbnails fit the size of the part’s face?

Well there may be a different type you can use to fill the frame up more (New ContentId format for easy thumbnail loading) but I’m not 100% sure

From what I’ve read on that thread it just seems like a faster easier way of doing the same thing as GetUserThumbnailAsync? I don’t see any extra capabilities

Then unfortunately I don’t think there is a solution, its just the way Roblox generates these thumbnails

Some solutions that come to mind are:

  1. Use editable image API - You can load the thumbnail as an editable image, use simple math to cut off the pixels you don’t want(the empty ones near the image borders), then load that edited image on the decal.
  2. Use a hidden part - You can set up a hidden part in front of the canvas that is larger but centered on top of the canvas, that way the image will appear larger as well.
  3. Use a surface gui with an image label - Instead of decals, you can use a surface gui and an image label, image labels offer more ways to scale the image by default, allowing you to make it as if it is “zoomed in”

Switch to SurfaceGui + ImageLabel instead of Decal, ImageLabel has ScaleType property that lets you set it to “Crop” or “Stretch” to fill the whole surface properly. Decals don’t have this control.

Does it stretch even into the transparent pixels of the image itself?