I’ve already found a “solution”. but, table.insert() does not work and i can’t really find a way for table.insert() to work.
code:
local myTable = {}
local metaTable = {
__newindex = function(table, key, value)
print("Value inserted:", key, value)
rawset(table, key, value) -- insert value
end
}
setmetatable(myTable, metaTable)
doing myTable["key1"] = "value1" is not really a good way of inserting a value inside a table in my case because i will need to debug a lot just to check if i set a value of a table right.
Explain what you are trying to do, and why. There is not enough context here to understand why inserting values to the table will not work via table.insert or any other method.
I am just trying to detect if a value is inserted in a table just simple as that. I have no clue why table.insert() is not working though it’s probably because table.insert() asks for the size of the table (?).
Just create an event that gets fired when you add an object to the table and pass the data inserted into the table through the event. You now have an event for when data is inserted into the table that you can listen to.