I'm trying to figure out how to "lock" a value in a table. Basically like:
local t = {
x = 1;
}
-- So if someone tried to change "x", it would be set back to default
t.x = 2
So, if someone tried to change a key (or the key's value) in a table, that already exists, how would i go about doing that? The __index and __newindex metamethods only work when the key doesn't exist, so is there any way i could make the script catch changes to existing data in a table?

1 comment
I would have thought that the __index metamethod catches changes in the value? Because it will usually cause a c-stack overflow when you try to change it without rawset inside the metamethod.