Problem with listing out accessories GUI

So I am trying to make a catalog Gui but I am encountering crucial problem, I’ve written some code to list out all the accessories in a folder, which is located in ReplicatedStorage, and make them in the actual Gui. So basically the function gets all the Values in a specific folder, and their sub-values and then Clones a button template and adds in the correct ImageId, Name, etc. My problem is that the code itself works but the image fails to load in and when trying to buy the item itself it fails saying the item is not for sale when it clearly is(Item is from the Roblox catalog), and I do not know why.


My Code
for _, v in pairs(game.ReplicatedStorage.CatalogAssets.Accessories.Hats:GetChildren()) do
	local templ = Template

	templ.Name = v.ItemName.Value
	templ.Image = tostring(v.ImageId)
	templ.Parent = CatalogUI.List.Accessories
	templ.ItemId.Value = v.ItemId.Value
		
		-- Buy Accessory
	templ.MouseButton1Click:Connect(function()
		MarketPlace:PromptPurchase(Player, tonumber(templ.ItemId.Value))
	end)
end
Gui Hierarchy

image

ReplicatedStorage Hierarchy

image

Not sure if you are using the AssetId of the product, but if you aren’t then thats the problem for the image not appearing, and most likely purchase failure.

This needs to change to:

templ.Image = “rbxassetid://” … tostring(v.ImageId)

1 Like

Still doesn’t work, and I’ve tried it before so yeah.

If you make the assetID a var then print it, what does it say?

local imageID = “rbxassetid://” … tostring(v.ImageId)
print("ImageID: " .. imageID )
templ.Image = imageID 

It printed the correct imageId it but I still get this error. 16:32:49.466 Image https://assetdelivery.roblox.com/v1/asset?id=1052732853 failed to load. Error 403: Asset type does not match requested type

OK. I checked that assetID out and it will not load on a normal button. Are you sure it is the correct assetiD and that it uploaded correctly?

You can check it for yourself, Dominus Praefectus - Roblox(Its a image)

Did you upload it via Studio or add it via the Website > Create? I would advise using the Asset Manager in Studio. If it helps at all, it gives me exactly the same error whether added via code or manually in to an ImageButton:
image

1 Like

Thanks it was probably a problem with the image itself, so I uploaded my own version and now it works!