Requiring a module breaks all of my scripts

After referencing my “ServerHandler” module it seems to yield all of my other scripts without giving any error in the output and completely breaking my game

Is there a limit to how many times a module can be required? I’ve required this same module many times in other scripts without it failing.

local ServerHandler = require(script.Parent.Parent:WaitForChild("ServerHandler"))

1 Like

What script/module is referencing ServerHandler. Also are there any error or warnings?

My LeaderHandler is where I’m trying to to require it from with no errors or warnings.

Before requiring:

After requiring:

In your leaderhandler right before you require the serverHandler. Can you print
print(script.Parent.Parent:FindFirstChild("ServerHandler")) and also print print(ServerHandler) right after you reference it.

Also are you referencing it any differently than your other module/scripts?

Make sure to test in studio and have output open!

It’s definitely referenced correctly.

It just prints the name but, after requiring the module it yields all of my other scripts.

Could you post the code thats inside serverHandler?

Also note that its 6am for me and I haven’t slept yet so if I stop responding it pretty much means I passed out. Hopefully someone else will be able to help you if that happens.

Try replacing the require with require(script.Parent.Parent.ServerHandler)

Wait are you requiring the module on the client? If so well then yeah the client doesn’t have access to server script service at all and hence it’l just wait forever.

It’s being required from the server

I’ve tried, it still doesn’t work

Are you using require() inside those modulescripts, and if you are can we see them?

It’s a lot of code to copy and paste but, none of the code in their should yield other requests from being made, especially since I’ve requested this same module from other scripts in the past with no problem.

What do you mean specifically? I do require other modules from a module.

This screenshot is taken from my “LeaderHandler” module:

(breaks my code)

This screenshot is taken from my “PlayerHandler” module:

(doesn’t break my code)

The only difference is the referencing path but, I’m positive both are referenced correctly

What’s happening is module 1 is requiring module 2 while module 2 is requiring module 1, this creates an infinite loop.

In your problem module, look at every module you require in it and then check if those modules are also requiring the problem module.

1 Like

You were spot on, I was requiring both modules. I’ll definitely try structuring my code a bit better.