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 » Scripters
Home Search
 

Re: Scripting Help

Previous Thread :: Next Thread 
wingnut163 is not online. wingnut163
Joined: 08 May 2013
Total Posts: 718
11 Sep 2016 09:56 AM
Long story short: I'm new and have been using the knowledge I have to make scripts. I have a question though about functions. What's the difference between:


function Name()
end

part.Touched:connect(Name)


and this:

part.Touched:connect (function

end)




All help is appreciated.




Report Abuse
yankana is not online. yankana
Joined: 17 Jun 2011
Total Posts: 431
11 Sep 2016 10:16 AM
Creating the function allows for multiple uses instead of having to write it down twice or more times. Functions without names are called Anonymous functions that are made directly, e.g. the second function in your post.
Report Abuse
wingnut163 is not online. wingnut163
Joined: 08 May 2013
Total Posts: 718
11 Sep 2016 10:17 AM
Thanks. Also, is it possible for me to have more than one anonymous function on one script?


Report Abuse
yankana is not online. yankana
Joined: 17 Jun 2011
Total Posts: 431
11 Sep 2016 10:19 AM
Yes, functions don't have limited amount of uses.
Report Abuse
wingnut163 is not online. wingnut163
Joined: 08 May 2013
Total Posts: 718
11 Sep 2016 10:19 AM
Thanks again! It means alot to me.


Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
11 Sep 2016 10:20 AM
The top one is an example of naming a function then connecting an event to it while the bottom is called an anonymous function because it doesn't have a name

Formerly ToxicDominator - add 17,509 posts
Report Abuse
wingnut163 is not online. wingnut163
Joined: 08 May 2013
Total Posts: 718
11 Sep 2016 10:20 AM
Thanks.


Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
11 Sep 2016 10:24 AM
Also, for most cases you might want to put "local" in front of your global variables since local variables are quicker to access; it would look like this:

local function Name()
end

and same with other variables

Formerly ToxicDominator - add 17,509 posts
Report Abuse
wingnut163 is not online. wingnut163
Joined: 08 May 2013
Total Posts: 718
11 Sep 2016 10:25 AM
Thanks for the tip!


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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