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!
-BluRayys
Things I’ve tried:
local ID = tonumber(TextBox.Text)
ImageLabel.Image = "rbxassetid://"..ID
ImageLabel.Image = "https://www.roblox.com/asset/?id="..ID
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: http://www.roblox.com/asset/?id=
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
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
else
warn(result)
end
return texture
end
-- test code
local texture = GetTextureFromAssetId(965496596)
print(texture)