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

Shared vs _G?

What's the difference? What can I do with shared that I can't do with _G?

1 comment

5

In general you should avoid using either! Consider ModuleScripts, BindableEvents and BindableFunctions as alternatives.

2 answers

✓ Accepted answer

There is no difference between shared and _G, they are, effectively, the exact same thing in two separate Tables.

shared is a byproduct of a security update that happened to _G which caused it to be removed for a few weeks. Basically, you didn't need to add a '_G' prefix to access its members before, and you did after. So shared was created to rectify this, and then a little later we got _G back, but not before a lot of people had already converted.

But like BlueTaslem said, both _G and shared are unnecessary and should be avoided as much as possible!

You can use _G. _G is a easier way to share values and probably player money to other scripts. It is a faster way. _G.String = "on_and_on" You can also print the string in another script: print(_G.String)

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