setscriptable
Toggles the scriptability flag of an Instance property.
function setscriptable(instance: Instance, property: string, value: boolean): booleanSynopsis
How it works
Modifies the
isScriptable flag on a property's PropertyDescriptor in the Roblox reflection metadata. When set to true, the property becomes readable/writable from Luau like any normal property. Returns the previous state so you can restore it when done.Under the hood
The
PropertyDescriptor is a C++ object shared by all InstancesInstanceThe base class for all Roblox objects (Parts, Models, Scripts, GUIs, etc.). Instances form a tree hierarchy (the DataModel). In Luau, they appear as userdata with shared metatables. of the same class. Setting it to scriptableScriptable (property)A property descriptor flag that controls whether a Roblox instance property is accessible from Luau scripts. Non-scriptable ("hidden") properties exist at the C++ level but throw errors when read from Lua. affects the property on all instances of that class, not just the one you passed. The change persists for the session unless manually reverted.Usage
Make a property scriptable
local wasScriptable = setscriptable(workspace.Terrain, "MaterialColors", true)
print(workspace.Terrain.MaterialColors) "cc">-- now readable
setscriptable(workspace.Terrain, "MaterialColors", wasScriptable) "cc">-- restoreParameters
instance Instance The target Instance.
property string The property to modify.
value boolean true to make the property scriptable.
Returns
boolean The previous scriptability state of the property.