Is there a way to detect if a value is added/removed in an table?

The title says it; is there a way to detect if a value is added/removed in an table?

There is __newindex method which fires when index is added/removed

local tab = {51,612,"Hi"}

setmetatable(tab, {
	__newindex = function(table, index, value)
		print("A new value was added")
	end
})

while task.wait(1) do
	tab[#tab + 1] = math.random(1,100)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.