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:
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.
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
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!