Reflection

gethiddenproperty

Reads a Roblox property with reflection metadata, including non-scriptable properties.

Syntax

gethiddenproperty(instance: Instance, property: string): any | boolean

Arguments

NameTypeDescription
instanceInstanceInstance object whose property should be read. Invalid Instance values raise an argument error.
propertystringProperty name resolved with Roblox property metadata.

Returns

NameTypeDescription
propertyValueanyProperty value, or nil as the only return value when no property descriptor exists.
wasHiddenbooleanSecond return value equal to !IsScriptable() when a property value is read.

Description

Reads a Roblox property with reflection metadata, including non-scriptable properties. The first argument must be Instance object and the second argument must be a string property name. The instance reference must be valid. If the property descriptor is missing from Roblox property metadata, the function returns only nil. If the descriptor exists but does not resolve to a property entry, it raises "Not a property". For Bool, Int, Float, Double, String, SystemAddress, SharedString, and Vector3 reflection types, the function calls the getter and returns the value plus a boolean equal to !IsScriptable(). SystemAddress returns RemoteId.PeerId as an integer. SharedString returns Content as a string. Vector3 reads from the instance primitive Size offset and raises "can't get value" if the touch data is missing. Other property types are read with normal Lua field access after temporarily setting the property scriptable flag to true; BinaryString is temporarily treated as String for that read. The original scriptable flag and BinaryString type are restored before returning.

Call it with 2 parameter(s): instance, property. The argument table explains which values are required and which ones only refine the behavior.

It returns propertyValue (any), wasHidden (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

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

local value, wasHidden = gethiddenproperty(workspace, "ClassName")
print(value, wasHidden)