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

Decal is not a valid member of Part?

Asked by 9 years ago

So for my stupid scripting mistake, but I can't get the decal in this script to go from 1 Transparency to 0. It keeps giving me an error as (16:47:30.928 - Decal is not a valid member of Part). It seems so simple for a beginner but I keep getting stumped why the Decal won't work...

Switch = script.Parent
Decal = game.Workspace.StaticScareWalkTo.Static.Decal

boolean = true

function onTouched(Switch)
    if boolean == true then
        script.Parent.Sound:Play()
        Decal.Transparency = 0
        wait(10)
    end
end

script.Parent.Touched:connect(onTouched)
0
That's because 'Decal' doesn't exist in the location you are referring it too. Perhaps it hasn't loaded or it's in a different area. DigitalVeer 1473 — 9y
0
I think it is loaded and in the correct position. Im sure. I did make the transparency at one so when you touch the brick the script will tell the decal to go to 0 transparency so you can see it mechasaultfreak2 10 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Try this. If it doesn't work I'm sorry there isn't enough for me to look at, hope this helps! :)

Switch = script.Parent
Decal = game.Workspace:WaitForChild("StaticScareWalkTo"):WaitForChild("Static"):WaitForChild("Decal")

boolean = true

function onTouched(Switch)
    if boolean == true then
        script.Parent.Sound:Play()
        Decal.Transparency = 0
        wait(10)
    end
end

script.Parent.Touched:connect(onTouched)

0
use the copy tool on the top right when you hover over the code DevScripting 92 — 9y
0
Please do not simply post code; Add some kind of explanation behind your answer, otherwise, the user will fail to understand 'Why is this necessary?', or, 'I don't see any changes in the code, it's the same code'. Please post some kind of Explanation. TheeDeathCaster 2368 — 9y
0
Explanation: You did not wait for the parts and decals to load, so you add a :WaitForChild("") to wait for the part or decal (child) DevScripting 92 — 9y
0
Ok thanks guys I understand now! mechasaultfreak2 10 — 9y
View all comments (2 more)
0
That is sort-of right, but, let me explain; The 'WaitForChild' method is a method where it will yield (pause/stop) the code, and will wait until a child with the matching name of the Argument has become existant within it's 'Parent' [Parent:WaitForChild(Child)], then, will return the Instance. TheeDeathCaster 2368 — 9y
0
Thats the exact same thing that I said... Just said differently DevScripting 92 — 9y
Ad

Answer this question