Hello Developers,
i made this module but my problem is the function keeps repeating leading to an error ReplicatedStorage.ModuleScript:8: C stack overflow . The function was runned once by a server script but it runned multiple times or in loop.
-- Server
local filter = require(game.ReplicatedStorage.ModuleScript)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
filter:Chatted(player,msg)
end)
end)
-- Module
local chat = {}
local metachat = {}
function metachat.__newindex(self,...)
local arg = {...}
print(#arg)
if not self[arg[1]] then
print(arg[1])
self[arg[1]] = {}
table.insert(self[arg[1]], arg[2])
else
table.insert(self[arg[1]], arg[2])
end
end
setmetatable(chat,metachat)
local filter = {}
function filter.Chatted(p,player,msg)
metachat.__newindex(chat,player.Name,msg)
end
return filter