Just wanting to know if this is bad practice or not: I have a main server script that loads my modules. If I now have 2 already loaded modules that need to use each others functions is it okay for these modules to require each other as well or am I supposed to try and keep the logic in such a way everything will work from the main script alone without the modules requiring each other? Hope that made sense.
1 Like
Unfortunately, you can not require a module, say module A, from module B, if module B has already required module A, as it results in a loop situation. From past experience, Roblox errors pretty quickly if you do this.
1 Like
Module 1:
local module = {}
local m = require(Module 2)
return module
Module 2:
local module = {}
local m = require(Module 1)
return module
That is a recursive function. It will error.
1 Like
I have a server script that’s required both previously so what if one module just requires the other once? Is that any different?
1 Like
If a server script requires Module A and Module B, then Module A requires Module B, it should be fine, as long as Module B does not then require Module A
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.