Skip to content

_G

Global · _G · server and client scripts

_G: { [any]: any }

_G is a table that all server scripts, or all client scripts of one player, read and write. A value a server script stores never reaches a client. _G keeps its values when a script reloads. Reading a name no script stored gives the built-in global of that name. For code that several scripts share, a module is clearer.

Example

-- Server script: count rounds across every server script.
_G.RoundNumber = (_G.RoundNumber or 0) + 1
print("round", _G.RoundNumber) -- prints round 1
print(_G.print == print) -- prints true