Reflection

sethiddenproperty

Sets a Roblox property with reflection metadata.

Syntax

sethiddenproperty(instance: Instance, property: string, value: any): boolean | nil

Arguments

NameTypeDescription
instanceInstanceInstance object whose property should be written. Invalid Instance values raise an argument error.
propertystringProperty name resolved with Roblox property metadata and the Instance class descriptor.
valueanyValue to write. The accepted value type depends on the resolved reflection type.

Returns

NameTypeDescription
wasHiddenboolean | nilBoolean equal to !IsScriptable() before a successful write, or nil when no property descriptor exists.

Description

Sets a Roblox property with reflection metadata. The first argument must be Instance object, the second argument must be a string property name, and the third argument must be present. The instance reference must be valid. If the property descriptor is missing from Roblox property metadata, the function returns nil. If the descriptor exists but does not resolve to a property entry, it raises "Not a property". Bool values use luaL_checkboolean. Int and SystemAddress values use integer type checking, with SystemAddress writing RemoteId.PeerId. Float and Double values use number type checking. String, SharedString, and BinaryString values use string type checking before calling the setter. For other property types, the function temporarily calls setscriptable(instance, property, true), assigns instance[property] = value with normal Lua field assignment, then restores the original scriptable state with setscriptable(instance, property, isScriptable). On successful writes, the return value is a boolean equal to !IsScriptable() from before the write.

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 wasHidden (boolean | nil). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Set a property value even when normal script access is limited.

local previous = sethiddenproperty(workspace, "Name", workspace.Name)
print(previous)