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

Why won't my asset images load?

Asked by 7 years ago
--Local Script
local cp = game:GetService("ContentProvider")
local toLoad = {}
for i,v in pairs(game.ReplicatedStorage.ItemList:GetChildren()) do
    for _,item in pairs(v:GetChildren()) do
        for index,value in pairs(item:GetChildren()) do
            if value.ImageId.Value ~= 0 then
                table.insert(toLoad, "http://www.roblox.com/asset/?id=" .. value.ImageId.Value)
            end
        end
    end
end
for i,v in next,toLoad do
    cp:Preload(v)
end

--Later in the script...
itemFrameClone.ImageLabel.ImageButton.Image = "http://www.roblox.com/asset/?id=" .. item.ImageId.Value

I tried pre-loading images, but it made no difference, unless I am doing it wrong. There is always an error that says "failed to load texture format" and the image never shows on the ImageButton.

Help appreciated, thanks!

1 answer

Log in to vote
0
Answered by
130363 67
7 years ago
Edited 7 years ago

When you want to turn an image or decal for a game, you have to change the asset IRL.To get the asset URL, you need to take the ID and subtract one (or two/three if someone uploaded something at exactly the same time as you). *Hint: you can use this method to copy any shirts, pants, and t-shirts. And I don't know if your script is right or wrong.

Example

https://www.roblox.com/catalog/156476828/Donation

would be come

https://www.roblox.com/catalog/156476827/Donation

Or

https://www.roblox.com/library/386230624/Roblox-decals

would become

https://www.roblox.com/library/386230623/Roblox-decals

Ad

Answer this question