Script that changes decal every few seconds

Hello, I am trying to make a TV screen change decals every few seconds.

This is what I have my Decal and Script nested under:
image

This is the current properties for the Decal:
image

And this is the script I currently have:

image = script.Parent

while true do
	wait(2)
	image.Decal.Texture = "6778205819"
	wait(2)
	image.Decal.Texture = "7062598370"
	wait(2)
end

Currently when I test, I only see the part without the decal:
image

While in studio, I at least see the decal on the screen:
image

I was wondering if there was anything wrong with my script, or the way I organized the objects. All help is appreciated :grin:

1 Like

You have to add http://www.roblox.com/asset/?id= before the IDs to make it work, therefore the script is

image = script.Parent

while true do
	wait(2)
	image.Decal.Texture = "http://www.roblox.com/asset/?id=6778205819"
	wait(2)
	image.Decal.Texture = "http://www.roblox.com/asset/?id=7062598370"
	wait(2)
end
1 Like

Try This

while true do
	wait(2)
	image.Decal.Texture = "http://www.roblox.com/asset/?id=6778205807"
	wait(2)
	image.Decal.Texture = "http://www.roblox.com/asset/?id=7062598365"
	wait(2)
end
4 Likes

I’ve changed my script now, however I’m still getting a white screen.

1 Like

Might have to use the rbxassetId prefix:

image = script.Parent

while true do
	wait(2)
	image.Decal.Texture = "rbxassetid://6778205819"
	wait(2)
	image.Decal.Texture = "rbxassetid://7062598370"
	wait(2)
end

How long ago did you upload the decals? They may still need to go through moderation if you just created them.

They’re decals I found in the library :sweat_smile:

I just tried @Thedagz’s solution using the ImageIDs and it seems to work

sharpie method may of worked too, Make sure to try his since his is better if it doesn’t then I guess its fine to use mine

Thank you! I tried yours thinking it was similar to what Thedagz posted, but turns out it really works :sweat_smile:

1 Like

My ID number is different so its not exactly the same

1 Like

If I try to add more decal ids, how do I know to use rbxassetid:// or http://www.roblox.com/asset/?id= before the id? I tried adding two more but when it gets to the new decals, it goes blank again.

How I did it was I put the ID number into the decal property, and then it usually changes that ID number, copy the new ID and paste that into the script… I dont know much about content URL’s but I believe using rbxassetid:// Should not have this strange behavior

https://developer.roblox.com/en-us/articles/Content

You can read more about how it works here

2 Likes

:wave:t2:KON’NICHIWA!, I can answer all your questions!
:question:Should I use http://www.roblox.com/asset/?id= or rbxassetid:// ??
Usually they both should work but its better to use rbxassetid://

:question:What is a good way to make images loop on my Decal?
You should use a table so you don’t have to constantly add another wait(2)

local image = script.Parent
--This way you can keep adding more images easily to the table.
local images = {
	"rbxassetid://6778205807",
	"rbxassetid://7062598365",
}
--You don't need to edit anything below this line :D
while true do
	for i, pic in pairs(images) do -- This goes through your images table 1 item at a time.
		wait(2)
		image.Decal.Texture = pic
	end
end

:question:Image wont appear?
The reason your images wont appear is because you need to get the image asset id not just the Decal id.

In studio you can do this easily by right clicking the image in toolbox and clicking “Copy Asset ID” as shown here:
image

This should solve all your problems! Good luck!
For more info on tables see:
Tables (roblox.com)

4 Likes

You just needed the assetId of the decal as opposed to the decalId itself, to get that in future you can just copy and paste the decalId into the “Image” property of the “ImageLabel” instance and the assetId will be provided.

Demonstration:
https://gyazo.com/efd4f1c519b35021eb504429ec846ff6

1 Like