We use cookies on this site to enhance your user experience

Global Functions

Global Functions

Aug 29 2019, 9:28 AM PST 2 min

A global function is a function which is present in _G, also known as the global table. The same _G is accessible from any script, so putting a function in _G allows any script to call the function.

Keep in mind that the server has a different _G than clients do, so you can’t define a global function in a server script and then use it from a LocalScript.

You may want to consider using BindableFunctions and BindableEvents instead of global functions. If you need to communicate from client to server or server to client, then you should use RemoteFunctions and RemoteEvents.


In one server script:

_G.hello = function ()

In another server script:

--> world!
  • lua
  • coding
  • concept