Raidorz
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 5221 |
|
|
| 02 Nov 2014 07:32 PM |
The wiki doesn't explain it well
Help please |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 02 Nov 2014 07:33 PM |
| Basically, if the event occurs then it connects with a function. |
|
|
| Report Abuse |
|
|
FlameYeti
|
  |
| Joined: 14 Jan 2009 |
| Total Posts: 22158 |
|
|
| 02 Nov 2014 07:33 PM |
function idk() script.Parent.Transparency = 1 end
script.Parent.Touched:connect() -- connect fires the script when its touched |
|
|
| Report Abuse |
|
|
xLink123
|
  |
| Joined: 07 Aug 2014 |
| Total Posts: 11158 |
|
|
| 02 Nov 2014 07:36 PM |
Connects the event fired, to the function
Ex:
script.Parent.Touched:connect(onTouched)
.Touched is the event, and it is connecting it to the function inside the parameter |
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 02 Nov 2014 07:37 PM |
The :connect method connects whatever you're using it on to a parameter inside the connect method. To make it simpler, here's a short diagram.
Event (Disconnected) | connect | function
You grab an event, and then connect it to the function with the arguments. If the event fires and returns something, and you haven't set the function, leave the function arguments blank as the thing returned from the event will be the argument of the function.
I'll give you a little script example of a changed event:
function Print(arg) print(arg) end;
x=Instance.new("Part",workspace) x.Changed:connect(arg) wait(1) x.Name = "hi"
This should print 'Name', as the changed event returns the property being changed and connects to the function.
|
|
|
| Report Abuse |
|
|
Raidorz
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 5221 |
|
|
| 02 Nov 2014 07:39 PM |
So when the part gets touched(Event), the brick turns invisible(function)
In order to do that you need to connect the part?
Or am I wrong?
|
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 02 Nov 2014 07:40 PM |
@12 "x.Changed" You didn't check if a property was changed, you checked if the part was changed. Don't you need it to be a property? |
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 02 Nov 2014 07:41 PM |
Yes, kind of. Once the brick is touched, since the event doesn't return anything except the part it touched, the function that you connected to the event will fire with the given argument being the part that it touched (the part that got returned from the touch event). |
|
|
| Report Abuse |
|
|
xLink123
|
  |
| Joined: 07 Aug 2014 |
| Total Posts: 11158 |
|
|
| 02 Nov 2014 07:41 PM |
| I noticed that too, but did not want to say anything because I might be wrong. |
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 02 Nov 2014 07:42 PM |
No, I was correct. If the part is changed, it will fire the changed event with the argument being the NAME of the property changed.
|
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 02 Nov 2014 07:44 PM |
Oops, the connect thing in my script example was a typo, change it to:
x.Changed:connect(Print) |
|
|
| Report Abuse |
|
|