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

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

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

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?

1 comment

0

Have you defined what 'Part' is? (E.G, local Part = game.Workspace.Part)

1 answer

✓ Accepted answer

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!

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