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 ..
1 | function onTouch(Part) |
2 | workspace.Part.Transparency = . 5 |
3 | wait( 2 ) |
4 | workspace.Part.Transparency = 0 |
5 | end |
6 | Part.Touched:connect(onTouch) |
but for some reason, it's not working. Does anyone know why this doesn't work?
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.
1 | function onTouch() |
2 | workspace.Part.Transparency = . 5 |
3 | wait( 2 ) |
4 | workspace.Part.Transparency = 0 |
5 | end |
6 |
7 | 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!