Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's the difference between local and _G?

Asked by
yoshi8080 445 Moderation Voter
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

What's the difference of using local and _G? I just want to know the difference and when to use them.

2 answers

Log in to vote
2
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

_G is a table that is shared across every script in a given environment (server separate from client separate from corescripts)

local is a keyword for defining variables in the local scope so that they cannot be accessed or changed outside of the block they are defined in.

Ad
Log in to vote
1
Answered by 8 years ago
_G --means global, a variable used for all scripts in the server

local --means it is a variable only used for one function

Answer this question