[Solved] Requiring Module Just Yields

Hello, for some very very odd reason, this one module I have just yields the script that tries to require it infinitely except the script that’s the parent of it. It returns no errors at all. Requiring works for every other module I have except this one. How would I go about fixing this? Anyone else experienced/experiencing the same?

Requiring line (from ‘Main’ localscript)
AnimModule = require(script.Parent.Animate.AnimModule)

Setup (explorer)
image

1 Like

Is it possible you have a WaitForChild(), a :wait(), or something else that would be doing it? It sounds like the script is just stopping & waiting at some line.

I’d probably need to see the code for your AnimModule otherwise to be able to help diagnose it

1 Like

Can you show us the code for the module? When requiring a module, code could yeild.

1 Like

It has one “loop” where it goes through all the descendants of the character to get its Motor6Ds, but this “loop” is in another module as well which got successfully required. Other than that this module only consists of functions and tables.

Motor6Ds = {}
for _, inst in pairs(Character:GetDescendants()) do
	if inst:IsA("Motor6D") and not inst:FindFirstAncestor("ViewModel") then
		Motor6Ds[tostring(inst)] = inst
	end
end

m["Motor6Ds"] = Motor6Ds
1 Like

Replace the code

require(script.Parent.Animate.AnimModule)

with

require(script.AnimModule)

I think that will fix your issue.

I’m having this issue too with a module that runs 8 of my places, requiring it yields until you rejoin the server while a player is already inside of it for some reason. Is this happening to you with other modules?

There could be many things that could be causing your module script you infinitely yield. Make sure that your modules are not requiring each other, as this will cause an infinite loop and make your scripts yield. Example:

--Module 1
local module2 = require(script.Parent.Module2)

--Module2
local module1 = require(script.Parent.Module1)

--This would yield infinitely as they are requiring each other over and over.

If this is not the case, use print statements and find what line the script reaches before yielding to narrow down what may be causing it.

1 Like

You have to return m. That would be why it is yeilding.

I do already at the end.
return m

Wasn’t in your post.

Because that’s just a part of it, it just shows the only loop I have in the module. You must have misunderstood. :face_with_raised_eyebrow:

Try adding a print before and after each of the loops/segments. See if you can pin down the part that’s yielding it. Also, add a print at the top of the module. If it doesnt print, the above is the problem.

Additional question: If a module (module1) requires a module (module2), that then requires another module (module3), then the module3 requires module1, could this cause it? Sorry for the awful explanation here. :expressionless:

Basically:
Module1 > Module2
Module2 > Module3
Module3 > Module1

As I said in my earlier reply, yes this will cause an infinite yield as they are requiring each other over and over.

1 Like

So what you’re saying is: if a circle consisting of 3 modules requires each other from left → right could cause the infinite yield ?

Well, if you think about it you’d see how it continues to require each other. Module1 needs Module2, but then Module2 says that it needs Module1, and so on.

The thing is: it yields aswell if I require it from a localscript instead of the module

If you make a loop, it will yeild

Yes, it will yield all scripts that have required it as when you require a module it yields until it is done initializing. However, it is stuck in an infinite loop of requiring each other, so yes, it will yield the local script.

It’s only this loop