setscriptable
Sets whether a property is scriptable.
Syntax
setscriptable(object: Object, property: string, scriptable: boolean) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
object | Object | The object, including an Instance |
property | string | The property name |
scriptable | boolean | The new scriptability |
Returns
| Type | Description |
|---|---|
boolean | The previous scriptability; false is returned for a property that cannot be resolved |
Description
setscriptable changes whether a property is accessible through normal scripting. This can make hidden properties accessible via regular property access.
Not every hidden property supports this operation. Changing scriptability can also be observable by game code, so restore the previous value as soon as it is no longer needed.
Example
local part = Instance.new("Part")
-- Make a hidden property scriptable
local wasScriptable = setscriptable(part, "size_xml", true)
-- Now we can access it normally
print(part.size_xml)
-- Restore original state
setscriptable(part, "size_xml", wasScriptable)Making Hidden Properties Accessible
local function exposeProperty(instance, propName)
local wasScriptable = setscriptable(instance, propName, true)
return function()
setscriptable(instance, propName, wasScriptable)
end
end
-- Use
local restore = exposeProperty(part, "size_xml")
print(part.size_xml) -- Now accessible
restore() -- Restore original stateRelated Functions
isscriptable- Check scriptabilitygethiddenproperty- Alternative for hidden properties