Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Shared vs _G?

Asked by
funyun 958 Moderation Voter
9 years ago

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

5
In general you should avoid using either! Consider ModuleScripts, BindableEvents and BindableFunctions as alternatives. BlueTaslem 18071 — 9y

2 answers

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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!

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)

Answer this question