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