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: local thing = or thing = ?

Previous Thread :: Next Thread 
killaman333 is not online. killaman333
Joined: 16 Jan 2013
Total Posts: 1143
25 Aug 2015 04:49 PM
Whats the difference between local and non local variables
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
25 Aug 2015 04:54 PM
Creating a local variable will make it only exist within its own scope (and sub-scopes from that scope). They also are created on register, thus they can be accessed faster.

Creating a non-local variable is called a global variable. Any scope can access it once it exists. However, it is slower to access.

When possible, use locals. In fact, I've NEVER had to create variables without local. Never. Just don't do it.
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
25 Aug 2015 05:00 PM
just use local. think of it as identifiying i suppose.

in javascript, you put 'var' in front of variables to make it only accessible in that scope.
if you dont, that means that variable already exists

use local to make variables, and not to manipulate them
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
25 Aug 2015 05:17 PM
local variables can only be called upon or edited via that script

not true for non local variables
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Aug 2015 06:21 PM
wowgnomes you're wrong, crazyman already explained it.

Global variables are stored in its enclosing's function's environment whereas local variables are stored on the call stack.

A Lua table lookup is much slower than just basic array indexing which is pretty much why local variables are faster.
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