What type is a ImageButton's Image property

Hello! So, I want to set an ImageButton’s Image property through an image ID that I have. When I do it by hand, and enter the ID in the Image property, it seems to come out fine and looks something like this: http://www.roblox.com/asset/?id=MyIdThatIPut
The “http://www.roblox.com/asset/?id=” came automatically, all I entered was the actual ID, something like, 1234567. Now, when I do the same function through code:

local MyID = 1234567 
ImageButton.Image = MyID-- Test ID

It actually sets the image ID to 1234567, instead of putting the placeholder of http://www.roblox.com/asset/?id=
So, trying another way, I decided to enter a string value, with a placeholder included, my code looks something like this now:

local MyID = 1234567 
ImageButton.Image = "http://www.roblox.com/asset/?id="..MyID

Now, it’s giving me an error that the type of ID I put into the Image property, is not the correct type. Tonumber does not work on that placeholder either as it’s not a number in any way. Does anyone know any solutions? Thanks!

Just do

ImageButton.Image = "rbxassetid://" .. ImageId

I tried that, but it doesn’t seem to work, the image comes out blank. Here is the image ID in case you need it: 6834854727. The actual image is the image of a Ball with a country’s flag on it. If you put in this ID manually into a ImageButton/Label, it seems to work fine, but this isn’t working for some reason. Thanks!

It’s probably because that’s it’s DecalId, try the ImageId: 6834854693

1 Like

Oh that worked! How do you check whether something’s a decal ID or an Image ID? And if it is a decal ID, how do you find the Image ID for it? Thanks for helping!

I use the extension BTRoblox

image

(The picture Icon redirects to the Decal’s ImageId asset)


You can use this though:

local imageId = "rbxthumb://" .. DecalId
2 Likes