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: When to use local?

Previous Thread :: Next Thread 
crazypeople203 is not online. crazypeople203
Joined: 09 Sep 2010
Total Posts: 289
28 Aug 2013 06:08 AM
Ok, so I know what local does, defines a variable for that "part" of the script, but when would I use it?
Report Abuse
luke111000 is not online. luke111000
Joined: 26 Apr 2009
Total Posts: 1853
28 Aug 2013 06:31 AM
I recomend looking it up on roblox.wiki.com
I would provide a link, but my internet is being slow.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
28 Aug 2013 06:39 AM
You use it when you don't want variable interference across scopes.
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
28 Aug 2013 06:47 AM
You would use a local variable when you don't want it to interfere with other blocks of code. Unlike global variables (which are created like locals, except you remove the "local"), this can be useful if you might be using the same variable for different purposes.

I'm not terribly high-tier on my scripting capabilities, but I'm fairly sure about what I know. If I'm wrong about anything, feel free to point it out.
Report Abuse
crazypeople203 is not online. crazypeople203
Joined: 09 Sep 2010
Total Posts: 289
28 Aug 2013 10:41 AM
Thanks guys.
My only question now is when should I use local?
Should I just use it all the time?
I suppose I'm fine without it, having my skills as low as they are.

And thanks guys. :D
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
28 Aug 2013 11:03 AM
1 reason is for utter laziness when you want to reuse a variable without tampering another function.

Another reason is to define before-hand so a value isn't returned nil.

I think that only happens when you use a variable function that uses it's own self inside that function.


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