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)
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
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
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.
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.
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.
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.