WierdTony
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 1116 |
|
|
| 04 Feb 2012 04:09 PM |
When I want Something to trigger, I make a function. I know how to do it, but the last line I don't.
function OnTouch(Bob) Bob.Transparency = 1 end
________________________
I don't get that line. |
|
|
| Report Abuse |
|
|
magnalite
|
  |
| Joined: 18 Oct 2009 |
| Total Posts: 2467 |
|
|
| 04 Feb 2012 04:14 PM |
That line there is called the "Connection Line" and basically that is the part of the script that define what calls the function so for that it would be -
script.Parent.Touched:connect(onTouch)
Although you can name the function anything you want EG"nom" it would just be this!
script.Parent.Touched:connect(nom)
and the part of the script you made would be this!
function nom(Bob) Bob.Transparency = 1 end
|
|
|
| Report Abuse |
|
|
WierdTony
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 1116 |
|
| |
|
|
| 04 Feb 2012 04:15 PM |
script.Parent.Touched:connect(function(Bob) Bob.Transparency = 1 end)
It's not easy being cheesy. I love Marilyn Mason,Sucicide Silence, and IWABO. Baseplate Maker Plugin here: http://www.roblox.com/Baseplate-maker-plugin-item?id=71012144
|
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:16 PM |
function OnTouch(Bob) Bob.Transparency = 1 end script.Parent.Touched:connect(OnTouch)
Touched is an event. Basically, an event waits for something specific to happen (for Touched, when one part collides with another part), then runs any functions associated (or linked) to the event. To link a function to an event, we use the connect method of the event.
Remember that anything the event returns (Touched returns the part that collided, Chatted returns the message, Selected returns the mouse, and so on) are passed on to the linked function as arguments.
If you're not quite sure what I mean, try reading this post: http://www.roblox.com/Forum/ShowPost.aspx?PostID=62145553 |
|
|
| Report Abuse |
|
|
WierdTony
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 1116 |
|
|
| 04 Feb 2012 04:17 PM |
| I always have trouble with the connection line. |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:20 PM |
Forgot to mention ....
To use a connection, you simply call the connect method with a colon and supply your desired function (that you want to run) as the argument.
Here's a generic representation:
Object.Event:connect(MyFunction)
MyFunction can be ANY function. You can also supply what's called an Anonymous Function. These functions are just functions you do not store in a variable.
Object.Event:connect( function() -- content of the function here end )
|
|
|
| Report Abuse |
|
|