So I was recently reading some toolbox scripts and practicing my coding skills by cleaning them up and making them more efficient when I came across a few lines I wasn’t sure I understood. They used the _G property, which when I looked it up on the documentation, it said it’s a table that is shared between all scripts of the same context level. So I guess if my scripts have the RunContext property set to the same Enum as other scripts, I can share information and data.
I’m not sure if I understood this correctly, so could someone please let me know if I’m not? Also, could I please have a better explanation or a maybe code sample? If so, thank you and have a wonderful day!
You can use _G on the server and the client but they do not replicate from one to the other which is why we say that the information is only shared in scripts of same RunContext.
I want to reiterate that _G is not a good solution; prefer to use ModuleScripts.