I’m currently trying to create a table using a metatable however I keep running into the error “C stack overflow”, here is my code:
local FlagMetatable = {
__index = function(Table, key)
warn(key.." does not have a table, creating one.")
Table[key .. "-flags"] = {1}
for i,v in pairs(Table[key]) do
print(i)
print(v)
end
warn(Table[key])
table.insert(Table[key], 1)
return Table[key]
end
}
The script calling it:
for i,v in pairs(FlagTable[Player.UserId]) do
if v then
v = v + 1
print(FlagTable[Player.UserId])
else
print(FlagTable[Player.UserId])
end
end
I would like the structure of the table to look like this:
local FlagTable = {
["userid"] = {
1
}
}
Any help is appreciated, thanks