ModuleScript over Global?

Hi guys - I’m looking to further my understanding of scripting with ModuleScripts as Globals etc.

So basically, I’m using a custom Framework that allows me to call modules and remote events with ease so for example:

local _Gi = _G
_Gi["Module"] = require(Module)

_Gi["Module"]:DoSomething(arg1, arg2)

After looking into this all I’ve seen that using Globals such as _G and Shared is REALLY bad practice. So how can I achieve this using other methods to help keep my framework easy?

Thank you!

Unless I missed a specific reason why this wouldn’t work in the post, you can just create a module script with all the shared functionality you need, and then require that module script in any script that needs to use it.

2 Likes

I think it’s my self preferred layout of coding so that I don’t have to using require each time and can just simply call stuff like

local ReplicatedStorage = _Gi[“ReplicatedStorage”]