generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I don't get the ':connect' part

Previous Thread :: Next Thread 
Raidorz is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image