Tables Cannot be cyclic?

For some reason, when a player joins the squad, it gives a “table cannot be cyclic” error. Any idea why?

Code:

-- // CONSTANTS \\ --
-- [ Services ] --
local Services = setmetatable({}, {__index = function(Self, Index)
	local NewService = game:GetService(Index)
	if NewService then
		Self[Index] = NewService
	end
	return NewService
end})

-- [ Modules ] --
local SquadsPlus = require(Services.ServerScriptService.Modules.SquadsPlus)

-- [ Remotes ] --
local Remotes = Services.ReplicatedStorage.Remotes

-- // Events \\ --
Remotes.CreateSquad.OnServerInvoke = function(SquadHost, SquadName, SquadRestricted)
	local Squad = SquadsPlus.new(SquadName, SquadRestricted, SquadHost)
	Squad.Changed:Connect(function(Squad)
		Remotes.ListUpdated:FireAllClients(SquadsPlus.SquadList)
	end)
	
	Remotes.ListUpdated:FireAllClients(SquadsPlus.SquadList)
end

Remotes.JoinSquad.OnServerInvoke = function(Player, Name)
	if SquadsPlus:GetSquadByPlayer(Player) then
		return false
	end
	
	local Squad = SquadsPlus:GetSquadByName(Name)
	if Squad then
		Squad:NewPlayer(Player)
	end
end

I believe rawset should be used instead, or else you’ll infinitely call __index. If that doesn’t work, then I have no clue where to look.

1 Like

Does seem to work, but not completely, so I will continue thinking over this. Thanks for trying though.