Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Are global functions used anymore?

Are _G Values used anymore for data? Example

_G.Cash = Instance.new('IntValue')
_G.Cash.Value = 100

-- instead of

local cash = Instance.new('IntValue')
cash.Value = 100

3 comments

0

Using events is a far better option than using global functions

0

Please give an example of like events

0

You can also use ModuleScripts instead of _G

1 answer

Here's some decent references for events

A remote event is useful for client-server/server-client communications http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions

A bindable event is useful for server-server communications http://wiki.roblox.com/index.php?title=API:Class/BindableEvent&redirect=no

Scripting helpers even made their own guide(s) https://scriptinghelpers.org/guides/server-client-relationship-in-roblox https://scriptinghelpers.org/guides/how-to-use-remoteevents-properly

3 comments

0

Oh i know how to use them, but does _G work well in filtering enabled, I get you can refer player as a parameter in them is that why?

0

_G is just inefficient in general and I would advise not using it

0

There is one _G variable per machine so the _G variable on the server would be different from the _G variable on each client.

This discussion is preserved as it was. New answers, comments, and votes are closed.