How would I use an image ID in a image button?

  1. I’m trying to make a script that changes a image buttons image depending on the decal ID inputted into a textbox.

  2. The script doesn’t change the image properly, even if I use the link that works in studio.
    Video: Video Link

As you can see in the video, it works if I manually input the ID into the image box as normal, but if I do the same thing in a script, it doesn’t work, even if I use the exact same manual path.

  1. I’ve tried removing the “http://www.roblox.com/asset/?id=” part, and just having the script enter the Decal ID, but that didn’t work. I’ve also tried using “rbxasset://” and then the ID, with still no success.

Code:

--Server side script
game.StarterGui.DisplayADsGUI.Frame.Placeholder.Image = "http://www.roblox.com/asset/?id="..script.Parent.AdvertismentFolder.Promotion1.DecalID.Value -- Simply tries to switch the current GUI image for one stored in a INTValue, but it fails to do it properly.

rbxassetid://[ID OF ASSET]

Use this.

https://www.roblox.com/asset-thumbnail/image?assetId=ASSETIDHERE&width=420&height=420&format=png

Will work also.

I’ve tried this already, and it didn’t work…

This didn’t work either, it only worked when I pasted it in manually.

That’s because you’re trying to modify the StarterGui from a local script once the game has started. Instead reference the correct UI element using script.Parent for example.

It’s a server side script, sorry for not clarifying this in the post.

player:WaitForChild("PlayerGui").DisplayADsGUI.Frame.Placeholder.Image = "http://www.roblox.com/asset/?id="..script.Parent.AdvertismentFolder.Promotion1.DecalID.Value

Surprisingly, that didn’t work. I’ve never come across this issue before, it’s so weird.

You’ll need to define the player object.

I defined the player, it still just showed a blank image instead of the image I chose.

May i ask what you are using to get the player with this server-side script?

And why not a LocalScript for these deeds?

I’m using a server script cause I just shoved it into the script which determined what ID to use, but I could try using a remote event and use a local script.

I just used

game.Players.PlayerAdded:connect(function(player)

It didn’t return an error with defining the player, the image just showed up blank.

I find this a bit hard to understand…a partially useless tip but you could try using variables and clear the
mess from the long assignments

(if that’s what they’re called)

Just tried a local script, and it still didn’t work. It works if I manually enter it by going into the playerGUI folder and then entering the ID, but not in a script.

What about remote events? Get the player to input the image ID, then to click a send button, then fire the image id through a remote event to the server and slap it onto the image button.

i see you placed a .Value there. If the value is integer/ number value, try to add tostring(Path to the value.Value)

To qoute message:
I think you should really used an remote events because when a user type something in the textbox, it only changes the client. So in the server its “” (Context text)/cleared text.

All you need to do is something like this

"rbxthumb://type=Asset&id="..DecalId.."&w=150&h=150"