Help with the error: Requested module was required recursively

Today I am encountering a very unusual error, it says that the Required module was required recursively, when I checked my code the error was coming from, There was no use of recursion there, then. why did this happen?
Error Log:

Requested module was required recursively  -  Client - ClassLoader:27
  16:05:47.277  Stack Begin  -  Studio
  16:05:47.277  Script 'ReplicatedStorage.Classes.ClassLoader', Line 27  -  Studio - ClassLoader:27
  16:05:47.277  Stack End  -  Studio
  16:05:47.277  Requested module experienced an error while loading  -  Client - Script:1
  16:05:47.277  Stack Begin  -  Studio
  16:05:47.277  Script 'ReplicatedStorage.Classes.ClassLoader.Script', Line 1  -  Studio - Script:1
  16:05:47.277  Stack End  -  Studio

The Code:

for i, v in pairs(CommonClasses:GetDescendants()) do
	if(v:IsA("ModuleScript")) then
		local a = require(v) --Error Line
	end
end
1 Like

Okay I found out that this module script was also requiring itself with other scripts, a quick fix to this was:

for i, v in pairs(CommonClasses:GetDescendants()) do
	if(v:IsA("ModuleScript") and v ~= script) then --Here adding a condition to check if V is not itself
		require(v)
	end
end

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