Roblox Developer Logo Get Started Learn Roblox API Reference Community

Global function

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: = function()

In another server script:
--> bar

See also