Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing an Imagebutton Image with script?

Asked by 8 years ago

So I am using a localscript to change the image of an image button. The localscript is located inside of the imagebutton. I have the link part put and then I'm trying to make the image id be the number found inside of an IntValue called ID.

script.Parent.Image=('http://www.roblox.com/asset/?id='.. (script.Parent.ID.Value))

However this doesn't work and I was wondering if there was a way to do this successfully.

1 answer

Log in to vote
2
Answered by 8 years ago

You made two errors there, actually...

Error 1
The ID of the image (the complete URL in this case) must go as a string, or the game will not know what you're trying to do with it as the '/' symbol is used for other things.

Error 2
You should use ROBLOX Images instead of ROBLOX Decals. If you do not know how to get the Image from a Decal, just go to the decal's page and change the part after '/asset/?id=' to the same minus one (e.g. if the ID is 83, then you change it to 82). Continue repeating this process until you get to your image.

In this case, the correct URL for your image is be 'http://www.roblox.com/asset/?id=378673539'.

I hope this helps, and happy coding!

0
Or you can just put it into the Image slot inside of anything with an image, and copy that Nootian 184 — 4y
Ad

Answer this question