Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Decal changing script doesn't work?

Hello all,

I am currently creating a TV and (hopefully) a working script that will change the Texture of the Decal after ever wait() that I do, but for some reason, it does not work.

Here's the script I've been trying to use.

--Variables--
local click = script.Parent.ClickDetector
local maindecal = "http://www.roblox.com/asset/?id=1241138052"
local decal = script.Parent.Decal
--Main Script--
click.MouseClick:connect(function()
	wait()
	click.MaxActivationDistance = 0
	wait(.2)
	decal.Texture = "http://www.roblox.com/asset/?id=1218165140"
	wait(3)
	decal.Texture = maindecal
	wait(1)
	click.MaxActivationDistance = 20
end)

I don't really know why this won't work, and it's such a simple thing too. Can someone please help?

1 comment

0

instead of changing the texture, why don't you just clone a pre-done decal?

1 answer

✓ Accepted answer

Your code seems fine, it's just a tad long. The problem is most likely that decals take time to load, so it will not work smoothly until the decals are loaded. You can preload them, but that's a bit complex for what you're doing.

If you try activating it a few times, does it work?

If not, I'm not to sure. If you'd like, a more efficient way to make a TV would to make a table of your IDs.

local decalIDs = {"id", "id", "id"}
local decal = script.Parent:WaitForChild("Decal")
local clickDetector = script.Parent:WaitForChild("ClickDetector")

function playTV()
	for i, d in pairs(decalIDs) do
		decal.Texture = d
		wait()
	end
end

clickDetector.MouseClick:connect(function()
	playTV()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.