Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What does the error "tables cannot be cyclic" mean and how can I fix it?

Asked by
Uglypoe 557 Donator Moderation Voter
9 years ago

I've been getting an error in testing on my game that says that "tables cannot be cyclic". The code is shown below. Is there a reason for why this is happening? Thanks!

LOCALSCRIPT1:

1plr.PlayerGui.Attacks.Frame.LocalScript.Spawn:Invoke(atks)

LOCALSCRIPT2:

01local at1 = script.Parent:FindFirstChild("Attack1")
02local a1 = nil
03local at2 = script.Parent:FindFirstChild("Attack2")
04local a2 = nil
05local at3 = script.Parent:FindFirstChild("Attack3")
06local a3 = nil
07local at4 = script.Parent:FindFirstChild("Attack4")
08local a4 = nil
09 
10function change(m1,m2,m3,m4)
11local atks = game.ReplicatedStorage.Attacks.AddAttacks:InvokeServer(m1,m2,m3,m4)
12for n,v in pairs(atks) do
13if not a1 then
14at1.Name = v[1]
15at1:FindFirstChild("Name").Text = v[1]
View all 56 lines...

SERVERSCRIPT:

01function game.ReplicatedStorage.Attacks.AddAttacks.OnServerInvoke(plr,m1,m2,m3,m4)
02local moves = {}
03if attacks[m1] then
04moves[1] = {m1,attacks[m1][1],attacktypes[attacks[m1][2]]}
05end
06if attacks[m2] then
07moves[2] = {m2,attacks[m2][1],attacktypes[attacks[m2][2]]}
08end
09if attacks[m3] then
10moves[3] = {m3,attacks[m3][1],attacktypes[attacks[m3][2]]}
11end
12if attacks[m4] then
13moves[4] = {m4,attacks[m4][1],attacktypes[attacks[m4][2]]}
14end
15return moves
16end
0
http://forum.roblox.com/Forum/ShowPost.aspx?PostID=155697586 . In short, a table that contains a reference to itself cannot be serialized (encoded into a transmittable format, such as JSON) properly. A brief test case that demonstrates this error is `t = {} t[1] = t game.HttpService:JSONEncode(t)` XAXA 1569 — 9y

Answer this question