Hello, i have a funny issue
We’re making in our game the possibility of setting images by id
aka user can go on creator store and chooses the image id what he wants to display
fun thing is that if you paste the id via script with formatting like rbxasset://...
or http://www.roblox.com/asset/?id=...
it doesnt work (the image is not displayed)
when i paste in by hand in the decal the id is totally changing
e.g https://create.roblox.com/store/asset/137072407447109/Cute-Chibi-Eyes-Head-Mask?pagePosition=3
turns into http://www.roblox.com/asset/?id=92298625139567
i have no idea how does work and i tried getting product info from MarketPlaceService
but there was no matching id in the result at all
does anyone has idea how to get the real image id from asset id?
137072407447109 → 92298625139567
local InsertService = game:GetService("InsertService")
-- Takes in a user input containing the assetId of either a decal
-- or image and returns an image assetId string ready for use or an
-- empty string if no assetId could be found.
function getImageFromUserInputAsync(decalOrImageAssetUri: string): string
local a, b = decalOrImageAssetUri:find("%d+")
if not a then
-- Return an empty assetId in the case of no id in input.
return ""
end
local assetId = tonumber(decalOrImageAssetUri:sub(a, b))
local st, result = pcall(InsertService.LoadAsset, InsertService, assetId)
if st then
local decal = result:FindFirstChildWhichIsA("Decal", true)
if decal then
-- Note: Do not directly parent the found Decal to avoid
-- security issues if untrusted Instances somehow ended up
-- underneath it. Instead, extract the id.
return decal.Texture
end
end
return `rbxassetid://{assetId}`
end