Syntax
setscriptable(instance: Instance, property: string, value: boolean): boolean | nilArguments
| Name | Type | Description |
|---|---|---|
instance | Instance | Instance object used as part of the scriptable override cache key. |
property | string | Property name resolved with Roblox property metadata and the Instance class descriptor on a cache miss. |
value | boolean | Scriptable override value to store in scriptable override cache. |
Returns
| Name | Type | Description |
|---|---|---|
previousState | boolean | nil | Previous cached scriptable value, previous scriptable state value, or nil when the property cannot be resolved to a property entry. |
Description
Stores a scriptable override for a Roblox property in the scriptable override cache and returns the previous scriptable state. The first argument must be Instance object, the second argument must be a string property name, and the third argument must be boolean. If a cache entry already exists for the same instance reference and property name, the cached scriptable value is replaced and the old cached value is returned. On a cache miss, the property name is resolved with Roblox property metadata and the Instance class descriptor. If no descriptor exists, or the resolved field is missing or is not a property entry, the function returns nil. When a property entry is found, the function reads scriptable state, stores the requested boolean plus the property reference in scriptable override cache, and returns the previous scriptable state value. The GameIndexHook and GameNewIndexHook later use this cache by temporarily setting the property field scriptable flag for a single indexed read or write, then restoring the previous field flag.
Call it with 3 parameter(s): instance, property, value. The argument table explains which values are required and which ones only refine the behavior.
It returns previousState (boolean | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Temporarily change whether a property is scriptable, then restore the previous state when available.
local previous = setscriptable(workspace, "Name", true)
print(previous)
if previous ~= nil then
setscriptable(workspace, "Name", previous)
end