Trying to update ImageLabel image with a script does nothing?

I’m trying to create a script that, when pressing a button, changes a sort of icon preview image to its respective item. Here’s the line of code that does this:

shop.PreviewImage.Image = "http://www.roblox.com/asset/?id=".. icon

Anybody know what I’m doing wrong? Also, “icon” is a series of numbers tostringed from an IntValue.

Can you show me other script? Also, do you have any errors in your output box?

Nope, no errors. The whole script is a tad long but for your viewing pleasure I’ll paste the whole thing below:

Summary

local shop = script.Parent.Shop.Main
local rs = game:GetService(“ReplicatedStorage”)
local purchasefunc = rs.PurchaseFunction --make this, when function fired locally, ask the server for the amount of currency someone has based on leaderstats, maybe use remotefunction to return true or false if it went through
local toolbar = script.Parent.Toolbar
local itemselected = false

shop.Position = UDim2.new(0.5,0,1.5,0)

–setting up names and prices–

shop.ObjDesc.Text = “Description of Object”

for i,v in pairs(shop:GetDescendants()) do
if v:IsA(“TextButton”) and v.Name ~= “Purchase” then
v.MouseButton1Down:Connect(function()
local price = tostring(v.Cost.Value)
local icon = tostring(v.IconID.Value)
shop.Price.Text = “$”… price
shop.ObjDesc.Text = v.Description.Value
shop.PreviewImage.Image = “http://www.roblox.com/asset/?id=”… icon
itemselected = v
end)
end
end

Sorry I couldn’t find an option for block code. Ironically, inputting the ID’s and that exact link into the image asset handler on the ImageLabel works totally fine. I’ve also tried “rbxassetid://[ID]” do no avail.

You did not define icon yet. Try add this to the top of the script:

local icon = tostring(123456789) -- change this to your image id

uh…I did?
local icon = tostring(v.IconID.Value)

each button that is clicked in the shop UI has an “IconID” value to pull from

Actually can you just show me the whole script? Because this is kind of tiring.

my slime the rest of the script is irrelevant

Try this then:

local shop = script.Parent.Shop.Main
local rs = game:GetService(“ReplicatedStorage”)
local purchasefunc = rs.PurchaseFunction --make this, when function fired locally, ask the server for the amount of currency someone has based on leaderstats, maybe use remotefunction to return true or false if it went through
local toolbar = script.Parent.Toolbar
local itemselected = false

shop.Position = UDim2.new(0.5,0,1.5,0)

–setting up names and prices–

shop.ObjDesc.Text = “Description of Object”

for i,v in pairs(shop:GetDescendants()) do
if v:IsA(“TextButton”) and v.Name ~= “Purchase” then
v.MouseButton1Down:Connect(function()
local price = tostring(v.Cost.Value)
local icon = tostring(v.IconID.Value)
shop.Price.Text = “$”… price
shop.ObjDesc.Text = v.Description.Value
shop.PreviewImage.Image = “http://www.roblox.com/asset/?id=”.. icon
itemselected = v
end)
end
end

what did you change? i cant seem to find a difference. if you’re talking about the “…” it got autochanged to an ellipsis

is it a local script or a normal script, if its a normal script it won’t work,

yall i promise im not a novice scripter of course its in a local script

try label.Image = "rbxassetid://".. tostring(id)

ive tried it, but i’ll try again.

also, im getting thrown a warning that is very nondescript: https://assetdelivery.roblox.com/v1/asset?id=7279839044 failed to load. Error 403: Asset type does not match requested type - Studio

edit: tried again with ‘rbxassetid://’ and I’m getting thrown the same warn.

Try adding a decal in workspace and putting the ID in there. If it changes, then you had the wrong ID, so paste the new ID it gives back into the script.

I’ve tried putting that exact ID into the actual image slot while not in test mode, and it works just fine. I’ll have it set to a specific image out of the eight im trying to use and when I try to select a different button it disappears.

Yeah, that seems to have given me the right ID. iirc i has something to do with the image-decal thing that for some reason is still around. I appreciate your help!