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: Question about global and local variables

Previous Thread :: Next Thread 
DukeCow is not online. DukeCow
Joined: 20 Nov 2010
Total Posts: 13176
04 Sep 2014 09:12 PM
Tell me if I'm right or wrong please.
Global Variable:
a = 1
Can access "a" in other scripts
Local Variable:
local b = 2
Can access "b" only in that script.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
04 Sep 2014 09:15 PM
Let's define local and global variables

Global variables -- Variables that are accessible anywhere WITHIN A SCRIPT

Local variables -- Variables that are accessible within THE BLOCK IT IS IN.
Report Abuse
DukeCow is not online. DukeCow
Joined: 20 Nov 2010
Total Posts: 13176
04 Sep 2014 09:17 PM
o...
So any way to put a variable like "a = 1" and access it in another script?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
04 Sep 2014 09:21 PM
It would be more complex than it should.
Report Abuse
DragonODeath is not online. DragonODeath
Joined: 02 May 2011
Total Posts: 1252
04 Sep 2014 10:01 PM
There're local variables. Which are only accessible within that block/scope
There're global variables. Which are only accessible within the script that it's in.
There're GREAT global variables. Which are accessible from ANY script.

To define a GREAT global variables, you must put them in the Global Table.

_G.variablename = VALUEHERE

To read more, see this page
http://wiki.roblox.com/index.php?title=Function_Dump/Core_Functions#G
Report Abuse
plistra is not online. plistra
Joined: 12 Mar 2014
Total Posts: 859
04 Sep 2014 10:09 PM
_G.varOne = 100 --accessed throughout any script
varTwo = 200 --only within the script
local varThree = 300 --only within the current scope(s)
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