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

Basic Scripting..why isn't this script working?

Asked by
EpicLilC 150
9 years ago

So i'm starting to learn how to script right now, and I got the basic things down, like for example, if I type ~~~~~~~~~~~~~~~~~ Workspace.Part.Transparency=0.5 ~~~~~~~~~~~~~~~~~in the command bar, it makes the brick transparent. So I started experimenting with scripting a little bit more and made this scripted ..

function onTouch(Part)
    workspace.Part.Transparency=.5
    wait(2)
    workspace.Part.Transparency=0
end
Part.Touched:connect(onTouch)

but for some reason, it's not working. Does anyone know why this doesn't work?

0
Have you defined what 'Part' is? (E.G, local Part = game.Workspace.Part) TheDeadlyPanther 2460 — 9y

1 answer

Log in to vote
1
Answered by
Ryukiyo 65
9 years ago

In the connection line to the function you need to define the Parent of Part , otherwise the script won't know where to locate the object that is being manipulated.

function onTouch()
    workspace.Part.Transparency=.5
    wait(2)
    workspace.Part.Transparency=0
end

workspace.Part.Touched:connect(onTouch) -- Defined where the object can be found

Questions / comments? Feel free to message me and I'll answer them as soon as possible. If you are satisfied with the answer I provided, please upvote me. Thanks!

Ad

Answer this question