Scripted image labels not working

I’m not sure if I should put this in #bug-reports:engine-bugs or not. Please tell me if I should.

So in my script it creates a new Gui with an image. I obviously set the image to something I uploaded. The problem is that the image doesn’t show up when it runs. I have to manually put it in for it to be visible. Is it a bug? Is there a way to fix this?
(By the way I uploaded the images on an alt because we all probably know how sketchy moderation is. I hope that’s not the problem.)

1 Like

This is a common bug. You could try relaunching studio, fixing the format of it. For instance, instead of putting only the id there you could put the whole rbxasset there instead.

This is not a bug. This is a common issue because of the difference of a decal Id and an image Id.

When you upload an image to roblox, it is uploaded as a decal type while roblox automatically uploads the image as the image type which has an id that is usually one less than the decal id (it may be a few IDs back depending on how many users are creating something on the site simultaneously)

Just grabbing the decal id and using it for the Image property of an imagelabel / button will not work, as it expects an image Id, not a decal id; however, manually inputting a decal id into an image object in studio will initiate a search for the corresponding image of the image asset type and will automatically change the image property when found, but this does not happen in-game: if you were to input a decal id, roblox simply does nothing and the image will not be loaded

As for finding the image Id from a decal id, it is rather “hacky”. My method would involve using a linear search over a few IDs and using GetProductInfo to determine the asset information. The thing about the images that are automatically uploaded is that they bear the same name and creator as the original decal, so we check for those, as well as if the asset type is of the image type:

local mps = game:GetService("MarketplaceService")
local decal_info = mps:GetProductInfo(ID)
local image_id = nil

for i = 1, 100 do
    local info = mps:GetProductInfo(ID - i)
    if info and info.AssetTypeId == Enum.AssetType.Image and info.Name == decal_info.Name and info.Creator.CreatorTargetId == decal_info.Creator.CreatorTargetId then
        image_id = info.AssetId
        break
    end
end

if image_id then
    print(("Image Id found: %d"):format(image_id))
else
    print("Could not find image Id")
end
4 Likes

So the decalID would be the numbers in the decal’s page URL right?

Precisely, if the asset type is decal