So in my game most exploiters are using metatables to stop bans and I would like to break them, I dont use them and it would only hurt the exploiters. Even if this breaks other parts of lua I can and will fix it but this needs to stop and this is my best bet.
From Programming in Lua, 4th Edition, chapter 20:
The functions
setmetatable
andgetmetatable
also use a metafield, in this case to protect metatables. Suppose we want to protect our sets, so that users can neither see nor change their metatables. If we set a__metatable
field in the metatable, getmetatable will return the value of this field, whereas setmetatable will raise an error:
mt.__metatable = "not your business"
s1 = Set.new{}
print(getmetatable(s1)) --> not your business
setmetatable(s1, {})
stdin:1: cannot change protected metatable
So, your answer? Set the __metatable
field to prevent access to a table’s metatable. Do that for all tables that you need to protect.