Ive seen alot of scripts with _G and i dont know whats it for can you help me?
What can i use _G for?
2 answers
You can use it for server-side script to server-side script tag values, so for instance I have _G.Tag = "Hello" in one script, and print(_G.Tag) in another script, the second script would print "Hello"
A table that is shared between all scripts in one instance of Roblox. Scripts can use this to share data, including functions, between them.
Notes:
In Online mode, scripts running in a LocalScript run on the player's computer, so they are in a separate instance of Roblox and can't share data with non-local scripts except by using objects such as IntValue. In the past, this was the table that all the built-in functions were stored in, and it was possible to read values from it without writing "_G" in front. This is no longer the case.
--Script one:
_G.variable = "This a variable in _G."
--Script two:
while _G.variable == nil do wait() end --make sure that script one sets the variable before this one tries to read it
print(_G.variable)
which would become when ran:
"This a variable in _G."
Source: _G
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I didn't even know this existed thanks dude.