Tables cannot be cyclic - but I can't find any cycle

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a modulescript that contains all of the modules, separated in Local (Server or Client) and Global.

  2. What is the issue? Include screenshots / videos if possible!
    It says “tables cannot be cyclic” and I can’t find where the cycle is.
    This is the output:
    16:58:48.477 tables cannot be cyclic - Server - Script:2
    16:58:48.477 Stack Begin - Studio
    16:58:48.477 Script ‘Workspace.Script’, Line 2 - Studio - Script:2
    16:58:48.477 Stack End - Studio
    It happens when I do this:
    But only when I call the Local ones from the server.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I asked many people, and looked through everything, put prints, and I still couldn’t find where the cycle is.
    No, I haven’t looked for any solution in the Dev Hub because I think it is something very specific to my code.

This is my all of the source:





EDIT1: I have redacted everything because I found what is causing the issue, and I am stating it here in case anyone comes across the same problem:

local Engine = {}
Engine.__index = Engine

return Engine
local GameModules = {}
for _, v in pairs( do --the previous mentioned engine included
   GameModules[v.Name] = require(v) -- error: "tables cannot be cyclic"

The issue disappeared when I removed “Engine.__index = Engine”
I am currently trying to find a solution and will edit once again when I do.

EDIT2: I am going to have to re-write the module. You can use .__index just fine but I messed up somehow.