How do i get a accesory image in a image label with a script?

so, yeah i dont really know how to do this, its for a avatar customization GUI that loads every accesory u have and gives u the option to delete it
image

2 Likes

Use viewport frame instead

local ImageLabel = script.Parent --YOUR IMAGE LABEL HERE 

local AssetId = "63690008" -- Pal Hair 

local ThumbSize = Enum.ThumbnailSize.Size48x48

local Size = string.split(tostring(ThumbSize):gsub("Enum.ThumbnailSize.Size", ""), "x")

local Width = Size[1]
local Height = Size[2]

ImageLabel.Image = "https://www.roblox.com/Thumbs/Asset.ashx?width="..Width.."&height="..Height.."&assetId="..AssetId

you cant request any number of thumbnail width and height size
you can only use sizes that are in the enum thumbnail size

1 Like

You should use make use of the “RbxThumb” ContentId format, it’s the most recent approach to loading thumbnails.

local imageLabel = script.Parent
imageLabel.Image = "rbxthumb://type=BundleThumbnail&id=192&w=420&h=420"

Here’s an example script which would make the image of its “ImageLabel” parent the Korblox Deathspeaker’s thumbnail.

You can learn more info regarding RbxThumb here:

1 Like

do u know if theres a way to detect what hat the players have? so i can put the image of their accesory and not a wrong one @Forummer

Yeah, you’d need to iterate over the player’s character’s children for accessories, then you’d get the IDs of those accessories and fetch their thumbnails accordingly.

theres no property called ID in the classname Accesory (which is used for the player’s accesories)

You have the accessory handle’s mesh properties but those won’t serve much use in regards to fetching their thumbnails.

Here’s a local script which you can use to get the IDs of accessories worn by any player’s character.

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

if not player:HasAppearanceLoaded() then
	player.CharacterAppearanceLoaded:Wait()
end

local description = humanoid:WaitForChild("HumanoidDescription")
local accessories = description:GetAccessories(true)
local accessoryIds = {}

for _, accessory in pairs(accessories) do
	table.insert(accessoryIds, accessory.AssetId)
end

for _, accessoryId in ipairs(accessoryIds) do
	print(accessoryId)
end

It makes use of the following instance method for fetching a character’s current accessories.
https://developer.roblox.com/en-us/api-reference/function/HumanoidDescription/GetAccessories