You've stated you're using ROBLOX. When you think about it, they've locked this stuff for a reason. Why? Security purposes. Allowing scripters access to such things is dangerous and poses a serious threat. So the answer is no, once locked there is no way back into the metatable without a reference, because if there was the lock would be pointless.
ROBLOX also got rid of all functions in the debug library, but the recently added debug.traceback
, so debug.getmetatable
is definitely out of the question.
However, depending on your reasoning for this, there are others ways to accomplish the task. I'll go over some of them here:
1) If you want to set the metatable of an instance, make a fake instance using your own table, and then use __index
and __newindex
to control access to the object's properties and methods
2) If you want to set the metatable of a library, we follow the same approach as in 1, create a fake table and use __index
to index the old table.
3) If you want to set the metatable of the global environment, set a new one with a pre-existing metatable. Make sure to use __index
so the other variables still work!
As for simply reading the metatables, no you cannot do this.
In addition to that, if you lock your own tables, as mentioned earlier there is a way to access the metatable. Simply store a reference to it. The best way to do it would be make a local variable called meta
in a do
scope block.
I hope this answers your question, I tried to specifically target ROBLOX, since that's what your question was asking.