setscriptable Synchronous

Override the effective scriptability of one reflected property. It returns the previous state, making temporary changes easy to restore.

Syntax
Luau
setscriptable(instance: Instance, property: string, enabled: boolean) -> boolean?

Parameters

Function parameters
ParameterTypeDescription
instanceInstanceInstance whose property visibility is being changed.
propertystringCase-sensitive reflected property name.
enabledbooleanBoolean state to apply.

Returns

boolean?

The previous scriptability flag, or nil when the property does not exist.

Usage notes

Changing scriptability does not itself read or write the property. Restore the previous flag after temporary inspection.

Example

Example
Luau
local part = Instance.new("Part")
local before = setscriptable(part, "CanCollide", true)
if before ~= nil then
    print("Now scriptable:", isscriptable(part, "CanCollide"))
    setscriptable(part, "CanCollide", before)
end
part:Destroy()
Kawaii documentation