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