Table Can Not Be Cyclic?!

I had read the previous snippet, Table.__index = Table.

As for the new information, you’re saying you’ve got a triple layered cycle? Table is the metatable of SubTable, which is the metatable of the SubSubTable inside SubTable?

Table[SubTable] isn’t being set to Table, it’s being set to {} with a metatable of Table

Overall, I am uncertain what you are attempting to achieve with this code. If you could describe the purpose of this whole structure, it would be easier to see if there’s some other, simpler way to do what you want.

I can’t say if it’s intended behavior or a bug but you can fix it easily;

for Bindables you would be better off using ModuleScripts,

for Remotes you can do many ways:

  • Separate the Data Table you are sending over the network

  • Clone the Data Table you are sending over the network

  • and many other creative ways



Thank you everyone your help is very much appreciated

2 Likes

This is not a bug - it’s just how Roblox processes cross-server communication and it’s been like this for years - same deal with mixed-key datatype tables.

3 Likes
I'm sorry if I've confused you let me explain myself more clearly;

I have a Players Manager Class that manipulates and stores each Player’s Data

PlayersData = {}

and for each player

PlayersData[Player] = {}

for each player they have many Sub-Tables but the most important one is SaveData

PlayersData[Player] = {SaveData = {}}

SaveData is very versatile, you can send it over the network with Remotes and also Save it to DataStore

PlayersData holds methods like AddEXP, AddMoney, etc that manipulates Player’s Stat stored inside PlayersData[Player].SaveData and also methods that manipulates Player’s Data inside PlayersData[Player]

I prefer to do PlayersData[Player].SaveData:AddMoney and use self but sometimes I might need to access something that is inside PlayersData[Player] and not inside PlayersData[Player].SaveData

and I would rather not pass things over to the method since I prefer having less parameters

I hope that clears up your concern :grin:

1 Like

It’s hard for me to be sure without seeing the whole script used to create this structure, but you should be able to provide access to other parts of the table using upvalues on the methods, instead of cyclic table references.

As @unix_system mentioned above, the cyclic table issue is a hard limitation of the networking in the engine and almost certainly won’t be changing.

1 Like

Any doubly linked list will create this error. It’s pretty annoying that there’s no way to know about this limitation until you’re days into writing your game.