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
 

_G Help

Previous Thread :: Next Thread 
LegendOfPhantom is not online. LegendOfPhantom
Joined: 27 Apr 2014
Total Posts: 101
22 Aug 2014 09:35 PM
What does this function do? Im kind of confused what it does and the wiki was confusing. Is it a function that can be accessed by other scripts?
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
22 Aug 2014 09:35 PM
script 1:

_G.hi = "hi"

script 2:

wait()
print(_G.hi)

Output: hi
Report Abuse
Hibobb is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
22 Aug 2014 09:40 PM
_G. creates a global variable, table, etc. What it means to be global is it can be accessed from any script. A normal use for this is scripts that deal with players. So one script would have:

_G.players = game.Players:GetPlayers()

And then another would go:


remaining = _G.players
randnum = math.random(1,#remaining)
target = remaining[randnum]
target.Character.Head:Destroy()
table.remove(remaining,randnum)
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