Reflection

Read and write hidden properties, raise or query thread identity, toggle scriptability, and check network ownership at runtime.

Overview

Roblox hides a lot of its own stuff from scripts: non-scriptable properties, values only the engine reads, ownership flags. Reflection gets you past that, mostly by changing thread identity.

Identity is a number for how trusted the running thread is. Your scripts run at 8 and a normal game script runs at 2. Some engine stuff only works at higher levels, and some game checks expect a lower one.

Hidden properties
-- Read a property Roblox does not expose to scripts.
local part = workspace:FindFirstChildWhichIsA("BasePart")
print(gethiddenproperty(part, "NetworkOwnershipRule"))

-- Make it scriptable, change it normally, then put it back.
local wasScriptable = isscriptable(part, "NetworkOwnershipRule")
setscriptable(part, "NetworkOwnershipRule", true)
part.NetworkOwnershipRule = Enum.NetworkOwnership.Manual
setscriptable(part, "NetworkOwnershipRule", wasScriptable)

-- Who owns the physics for this part right now?
print(isnetworkowner(part))

Set identity back

If you lower your identity for a call, put it back afterwards (ideally in a pcall cleanup). A script stuck at identity 2 loses access to most of this API and it'll look like the functions are just broken.

Thread identity

Hidden properties

Scriptability

Physics