I’m surprised decals are even a thing still, it feels really strange that we have a web asset that doesn’t actually do anything (since decal instances need an image id, not a decal id).
I’d be much happier if Decals were hidden from the website, and stopped being created when an image is uploaded - it’s much easier to view the actual image assets now with the create.roblox.com/creations page.
An exposed method which handles this for us would be much more generous than us having to use (and some day, people will find) this example (which honestly I did not know you could do this).
The API would be a quality of life change that would be well received with opened arms.
This seems really esoteric and is not common knowledge nor easy for people to figure out; if you browse the forum you can see that the general approach people take towards doing this is to use crazy hacks or simply do something else. This is too close to being a hidden trick that I don’t think doing this in this manner should be considered canonical.
If we add something akin to MarketplaceService:GetAssetFromDecal() or AssetService:GetAssetFromDecal(), how would it be any more discoverable than those two methods? If developers cannot find either of the existing ones, is this new API different?
This workaround relies on knowing that creating a decal results in the texture field being set to the image id. This behavior is only directly observed in Studio through the properties widget when you try to set the texture property and it’s easy to assume that it is Studio doing that conversion, not the instance itself.
Developers will go to Google or to the DevHub first and will typically try searching directly, or else browsing API pages for related services. In many cases they may just try intellisense directly in Studio and hope they get lucky. It is massively easier to discover an API function that directly does this than it is to connect the dots and come up with some workaround that jumps through InsertService. The existence of this function in intellisense under a logical service would improve discovery without leaving Studio, and the existence of the DevHub API page for a function like this with sufficient keywords on the page would solve this through search engine indexing.
There’s a big difference between a method designed and advertised to do a specific task and a sequence of methods that happen to make the functionality possible via a still overly complex workaround. Kind of like how we have helpful coordinate math functions like CFrame.lookAt despite us technically being able to achieve the same functionality through other more complex means.
LoadAsset doesn’t allow us to import assets that are not owned by Roblox or the Game owner.
For players to use decals their own, how exactly can this suffice that use case?
An asset loaded by this function must be created or owned by either the game creator or Roblox. Additionally, benign asset types such as t-shirts, shirts, pants and avatar accessories are loadable from any game as they are public.
I know this method exist but never cared for it because of this flaw
Clearly there’s metadata somewhere in a decal asset that links it to the image ID. I agree that this would be great to have without needing to go through both MarketplaceService and InsertService.
Whoops, I shouldn’t have used the word “method” as it has multiple meanings here. I understand that the API methods are well documented, I meant the method (as in technique/solution) that you shared uses those APIs in a clever way that doesn’t seem to be mentioned anywhere and is only obvious if you already know about it.
After switching the -n technique to your given InsertService technique, I was met with this:
InsertService cannot be used to load assets from the client
The workaround you provided doesn’t work on the client, which is extremely inconvenient.
After reworking it to be on the server, I found that this suggested workaround is still does not work, since InsertService cannot insert assets that you don’t own.
HTTP 403 (Forbidden)
An asset loaded by this function must be created or owned by either the game creator or Roblox. (Source)
The goal in our aforementioned use cases is to allow players to use custom images that they own, so this completely defeats the purpose.
So, unfortunately, my original post’s method is still the only currently available hack.
To add onto this, we shouldn’t have to ask users to open their inventory for us to grab the image that we need. The current method supplied depends on us making sure the client’s inventory is available for us to view, which seems really sketchy if you ask your players to open their inventory. A solution that provides the image without this hassle would again be a quality of life feature that we need.
Even if they make the decal public, the InsertService call will still throw an error.
The documentation is correct in stating that the asset must be owned by you or Roblox.
I would say “I’m surprised this was suggested so late”, but you consider how these assets are created, and anything earlier than the past three years or so didn’t need this API because it was as easy as ID-1, simply because asset uploads were less frequent than they are today. This worked beautifully for years but these days it’s just not viable anymore with how many people are uploading content onto the platform.
This has been a huge issue for me as well. I flat out don’t even know how to automate this, and have always resorted to just manually grabbing the image ID for my assets and baking them into my scripts as hardcoded strings. User input has always relied on the user just getting the ID on their own.
I think something like a marketplace API call would be the best because it doesn’t rely on having a script insert assets into your game, it doesn’t require you to own the ID as per the limitations of InsertService, and it’s straightforward.
If anything, I’d vouch for it being a member of ContentProvider because that seems more mnemonic in my opinion (ContentProvider:GetImageFromDecalAsync(decal) makes more sense to me than MarketplaceService:GetImageFromDecalAsync(decal) does, for example)
For anyone wanting a direct URL that’s valid with textures/image inputs ingame in realtime without needing to worry about LoadAsset, you can input this at the cost of image quality until they make an actual function for it
Since it’s technically grabbing the thumbnail of the asset, it should work with model/audio/video/mesh/plugin thumbnails as well. Not really useful for needing to get an actual image ID for studio purposes but works pretty well for having players input decal IDs for custom images etc.
For example, I’d like to allow users to use their own decal in a game. There is no user-friendly way for someone to get the image ID from the decal ID. The average Roblox player wouldn’t know how to do this.
This is frustratingly annoying, this really needs to be a built in feature that works with other players assets as well so we don’t have to do some hacky workaround to get the imageID.
I agree this is necessary. I have several use cases for user selected images in my game. Most users have no clue how to get the image id, and Roblox only shows the Decal Id in their inventory. I currently use a proxy API and the assetdelivery API to retrieve the image id if decal id is supplied. This is costly since there’s a finite 500/min budget and forces me to rate-limit changes. Adding this method should be trivial.
Side note, it’d be great if we could also get properties or a method to get the width & height of an image for determining aspect ratios. I have to use HttpService to pull in the image data and parse for them. Not optimal at all when this info is known by the engine.
Bumping this thread because I’m running into an issue utilizing Open Cloud and external applications now with the inability to get image ids from decal asset ids.
I’m externally editing rbxmx files and directly inserting ids into models, however, I cannot use the decal asset ids, i have to use the decal image ids, which do not automatically get converted when the model is imported.
Using this for surface appearance importing automation.
Also on a side note, Open Cloud’s mesh upload does not allow you to directly get the mesh id either, you get given the model asset id because ‘fbx meshes’ are uploaded under the Models tab.
EDIT: yes I have looked through the Open Cloud APIs and available APIs in webpoints; they do not provide the image id directly and only provide the asset id.