What does module recursion happen here?

let me try to replicate what I tried in a simple way

explorer

  • module script
    • script
    • module script
module script(parent)
local Module = {}
local Module2 = require(script.ModuleScript)

Module.new(Module2.new())

return Module
module script(child)
local Module = {}
local Module2 = require(script.Parent)

Module.new()

return Module
script(child)
local Module = require(script.Parent)

Module.new()

so what is my problem?
I keep getting this error (Requested module was required recursively)
this error happens whenever I have “local Module2 = require(script.Parent)” in the module script(child) script

my main question is how does this even cause recursion in the first place???

Because you’re requiring the ModuleScript (parent) which requires the ModuleScript (child) which then runs that and requires ModuleScript (parent) when runs require(script.ModuleScript) which then runs require(script.Parent).

1 Like

oh yea actually that makes a lot of sense now
thanks a lot I’ll make this the solution