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

Decal changing script doesn't work?

Asked by 7 years ago

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?

0
instead of changing the texture, why don't you just clone a pre-done decal? Astralyst 389 — 7y

1 answer

Log in to vote
0
Answered by
Eqicness 255 Moderation Voter
7 years ago

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)
Ad

Answer this question