How to fix recursively required module error

  1. What do you want to achieve? Keep it simple and clear!
    So i need to get this module
    image
    from this one module
    image

  2. What is the issue? Include screenshots / videos if possible!
    issue what i get this error
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I had looked though few posts but i didn’t really understand how to fix this

1 Like

Hey,
Could you please post the code that errored for you (e.g., from the module script, server script or likewise)?

local PlayerManager = require(game:GetService("ServerScriptService").PlayerManager)

There is this topic which explains solutions to module required recursion, I’d suggest looking at it and seeing if you can get anything from it.

Apart from that, in short, make sure that you are not requiring a module which has that same module required. For example, requiring A in B and then also B in A, that would cause recursion.

With a single line of code, I cannot help you much apart from that.

1 Like

The problem is that the PlayerManager module is requireing the module with this code.

1 Like

No it’s not, playerManager not require this module, it requires
image
this module, but not commands

I saw that posts few times, i can’t really understand how to fix this recursion there. Because i’m not requiring A in B there

Ok, but what modules does Console require? And what modules do those modules require? Eventually, somewhere along the line it will try to require PlayerManager, which causes the error because then it will try to require Console and so on, looping forever.

Try using Ctrl+Shift+F to find all requires, that could help speed things up.

image
PlayerManager require console
image
Console require commands
image
Commands require PlayerManager

Console require Commands, Commands require PlayerManager, PlayerManager require Console.
Console -> Commands -> PlayerManager -> Console -> Commands -> ...
You need to change something.

I’ve done PlayerManager require inside of a function where it needs to use in Commands. Will this fix that?
EDIT: Seems to work

If it works then please close the thread.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.