Hello, i'm currently making a sandbox for my script builder and i noticed that metatables don't stay in my sandboxed tables, how can i return a sandboxed table with the metatables that it had? I'll put the wrap function only with the table part

function wrap(real)
if type(real) == "table" then
local fake = {}
for k,v in pairs(real) do
fake[k] = wrap(v)
end
return fake
end
end

Also sorry if this is not too descriptive but i really need help, getmetatable() doesn't work if the real table has a locked metatable.

1 comment

0

You can’t get the metatable if it’s locked, but have you tried attaching a meta table to fake which in turn replicated changes to and from real, allowing real's metatable to affect what happens in fake as well.