Why can I change an image in studio but not with a script?

I’m making a sort of in-game catalog, apparently you can set a catalog item’s id as an image because I did that in studio and it works fine, however when I do that in a script it doesn’t work. It does change the image property, but the image becomes invisible as if the id is invalid. (It doesn’t error though).
Here’s my script:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(p, Icon, Id)
    Icon.Image = "http://www.roblox.com/asset/?id="..Id
end)

(Another script fires the remote event)

Anyone know why this isn’t working? Is “http://www.roblox.com/asset/?id=” the wrong prequel to use in this case? When I enter the id as the image in studio it automatically sets that as the prequel so I assume it’s right.

Pretty sure you have to use " rbxassetid://"
Could be wrong though /shrug

2 Likes

Pretty sure you have to use " rbxassetid://"

Yes you will need to use rbxassetid:// if you want to change an image inside of a script by replacing the ID.
If you are going to change the image by concatenating the ID with the preset roblox image link(don’t know if thats the proper name), but you will need rbxassetid://

script.Parent.RemoteEvent.OnServerEvent:Connect(function(p, Icon, Id)
    Icon.Image = "rbxassetid://"..Id
end)

I do believe you have to use rbxassetid, like “rbxassetid://”
Try this,

script.Parent.RemoteEvent.OnServerEvent:Connect(function(p, Icon, Id)
    Icon.Image = "rbxassetid://"..Id
end)

I swear I’ve ran into an issue like this before Roblox image Id system is weird and an image will only show up if you have the correct id but taking the id from the website doesn’t work so you have to first create a decal paste the first id in there copy the new id then use that I don’t know why you have to do that but that’s the only way I know how to do it

rbxassetid:// doesn’t work either, this isn’t an image id, it’s a catalog item id. Whenever I type in an image id it automatically puts rbxassetid:// as the prequel, but with the catalog item id it puts “http://www.roblox.com/asset/?id=” as the prequel, so that’s probably the right way for catalog items.

Oh, so you are trying to get the catalog item’s image from the item?

You will need to use https://www.roblox.com/asset-thumbnail/image?assetId=26769281&width=420&height=420&format=png and input the ID for the item where it says “assetId=NumberHere”

script.Parent.RemoteEvent.OnServerEvent:Connect(function(p, Icon, Id)
    Icon.Image = " https://www.roblox.com/asset-thumbnail/image?assetId="..Id.."&width=420&height=420&format=png"
end)

Nope, the image still doesn’t pop up. Here’s what I did:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(p, Icon, Id)
	Icon.Image = "https://www.roblox.com/asset-thumbnail/image?assetId="..Id.."&width="..Icon.AbsoluteSize.X.."&height="..Icon.AbsoluteSize.Y.."&format=png"
end)

That’s exactly what I did.

Try to do

print(Id)

and see if it prints the Id you are looking for, as it might not be passing correctly.

It does. As I’ve said it does change the id correctly but the image still doesn’t show up.

I still haven’t found any solution

i think this might work: “rbxthumb://type=Asset&id=IDHERE&w=420&h=420”

edit should work just tested it out!

3 Likes