Something went wrong with decal changing

Hello , my idea is to make TV that will show other decals when player click red putton . But my studio shows me this error
image
and here is a script wich I use in button

local decals = { 161023603,474498948,2837630409,2389399394,3412119510,4737538383}
local TVMonitor = game.Workspace.TVMonitor
local button = script.Parent

button.ClickDetector.MouseClick:Connect(function()
	TVMonitor.Decal.Texture = math.random(1,#decals)
end)

Thank you for reading !

You settings the Texture to the id from 1 to the length of the decal.
Index these in arrays:

TVMonitor.Decal.Texture  = decals[math.random(1,#decals)];
1 Like

You should use “rbxasseId://” before your assetId so it’s better for loading, if doing this doesnt work then preload your decals with the ContentProvied and PreloadAsync.

Forgot to index the table, oops


TVMonitor.Decal.Texture = "rbxassetId://" .. decals[math.random(1,#decals)]
1 Like

Maybe there is a mistake ?

button.ClickDetector.MouseClick:Connect(function()
TVMonitor.Decal.Texture = "http://www.roblox.com/asset/?id=" .. decals[math.random(1,#decals)]
end)

It doesn’t want to work still . I also tried rbxassetId:// like you said

Maybe try using PreloadAsync from the ContentProvider, this will make whatever is inside the given table will be a priority of the que. Hyperlinks for both are in my earlier reply