Metatable
The metatable functions allow elevated access to locked metatables.
getrawmetatable
Returns the metatable of object
, where the __metatable
field would normally lock the metatable.
Parameters
object
- An object with a metatable.
Example
hookmetamethod
Replaces func
with hook
internally, where hook
will be invoked in place of func
when called.
Returns a new function that can be used to access the original definition of func
.
⚠️ Not yieldableThe function
hook
is not allowed to yield or block the thread.
⚠️ RecursionTry not to invoke
method
from within the functionhook
! For example, do not index a property of an Instance from within a hook to__index
.
Parameters
object
- An object with a metatable.method
- The name of the method to hook.hook
- The function to replacefunc
with.
Example
Prevent scripts in PlayerGui from invoking the __namecall
hook:
getnamecallmethod
Returns the name of the method that invoked the __namecall
metamethod.
Example
Bans the use of game:service()
:
isreadonly
Returns whether object
is frozen or read-only. Identical to table.isfrozen
.
Parameters
object
- A table or userdata.
Example
setrawmetatable
Sets the metatable of object
to metatable
, where the __metatable
field would normally lock the metatable.
Parameters
object
- A table or userdata.metatable
- The metatable to set.
Example
setreadonly
Sets whether object
is frozen or read-only.
Parameters
object
- A table or userdata.readonly
- Whether or notobject
should be frozen.
Example
Last updated