How to get Asset ID from Decal ID?

Hey there! Currently having a problem with setting an Image ID through script. The ID changes but it does not show the image. I have came to the conclusion that its changing the ID but not converting it into an Asset ID. So how do I convert a Decal ID to an Asset ID? I’ve surfed the web trying solutions but nothing is working. Thank you for your time!

Things I’ve tried:

local ID = tonumber(TextBox.Text)
ImageLabel.Image = "rbxassetid://"..ID
ImageLabel.Image = ""..ID
1 Like

The Id given is the AssetId of the Image, The Id then applies what Image is there under that Id, it doesn’t really make since to do tonumber() if its already a number

You misspelled the Link btw, its:
you just added an s to http

(looking now, no, im wrong, you can spell it with an s)

Its weird because you need to apply the Id (only the numbers), when doing so manually, it adds the link, but doing it by script, it doesn’t recognize it

You can look at this if you like:

As you can see here, I put a Decal ID in the Text Box.

It did end up changing the ID but nothing shows, this is my problem.
but by putting the Asset ID version of the Decal it does show, I just need to figure out how to get the other version of the Decal ID.

Try fetching the asset using InsertService then indexing the Texture property of the returned asset for the correct URL. (a similar method is also used for shirts/pants)

local insertService = game:GetService("InsertService")

local function GetTextureFromAssetId(assetId: number): string?
    local success, result = pcall(insertService.LoadAsset, insertService, assetId)
    local texture
    if success then
        local asset = (result::Model):GetChildren()[1]
        texture = asset.Texture
    return texture

-- test code
local texture = GetTextureFromAssetId(965496596)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.