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: _G

Previous Thread :: Next Thread 
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:05 AM
What does that do? and what does _index do ?
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:12 AM
bump!
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
01 Jan 2011 08:16 AM
_G is a global table. You can add variables to it and those can be accessed in other scripts (I dont think client-side scripts can get server-side globla varaibles)


EG:

Script1:

_G.LOL = "LOL"


Script2;

print(_G.LOL)

OUTPUT:

>LOL
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:16 AM
BUMP,ET!
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:16 AM
UHG ANOTHER LATE PST BY ME D:
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
01 Jan 2011 08:18 AM
Blame life. Or John.
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:18 AM
So its a substitute for source?
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
01 Jan 2011 08:19 AM
Script.Source? Not really, I dont think. You can hold functions, numbers, strings... ANything that can be in a normal table.
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:20 AM
well i mean like

_G.print = game.Workspace.Part1:remove

script;

... O wiat nvm.. But you could insert that unto a table i guess.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
01 Jan 2011 08:22 AM
Well, you COULD do _G.print = function(var) workspace.Part1:Remove() end
_G.print("LOL"
Report Abuse
YodaimeKing is not online. YodaimeKing
Joined: 01 Nov 2009
Total Posts: 3961
01 Jan 2011 08:59 AM
Wait how does that work?
Report Abuse
bloob827 is not online. bloob827
Joined: 01 Aug 2010
Total Posts: 6867
01 Jan 2011 09:17 AM
__index is a metamethod, _index is nil. >_>

__index fires when something is looked up in a table.

For example:

table = {"hello", "hi"}

metatable = {__index = function() return print("no access allowed") end })

setmetatable(table, metatable)

print(table[2]) > no access allowed

Or:

table = {"hi", "hello"}
setmetatable(table, {__index = function() print("TheRandomText") end })

print(table[1]) > prints 'hi' and prints 'TheRandomText'
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