Failed to load from table

Hello,
I’m trying to create a script where every once and a while it will pick a random asset id (decal) from a table. However, I’m running into a problem where when I try to load the asset into the game, I get an error saying that the request failed.

Direct error:
Image “https://assetgame.roblox.com/asset/?id=1255785935” failed to load in “Workspace.Screen.SurfaceGui.Frame.Frame.ImageLabel.Image”: Request failed

Script:

local images = {1255785935, 1255792029}
local screen = game.Workspace:FindFirstChild(“Screen”)
local imagelabel = screen.SurfaceGui.Frame.Frame.ImageLabel

while true do
wait(10)
local newimage = images[math.random(#images)]
imagelabel.Image = “rbxassetid://” … newimage
end

I’ve tried using Preload, but i’m not really sure how to use it correctly (looking at Wiki). Is anyone able to help me and point me into the right direction?

Thanks,
Surgo

1 Like

The way Roblox stores images is weird. When you upload a decal, two assets are created:

  • The decal
  • The image asset

Inserting the decal gives you a decal instance. The image asset is what you can apply to the Decal Texture / ImageLabel Image / etc properties. The reason your script is breaking is because you’re trying to set the image to a decal instance instead of an image asset. The ID provided by the website is the decal instead of the image.

To get the image asset, you can paste the decal ID into an ImageLabel/Decal image property and Studio will automatically convert it to the image asset ID for you. After it’s converted, you can copy and paste it back into your script.

3 Likes