Objects & instances
Inspect Objects and Instances, read callbacks and save models.
The Instance API finds cached objects, creates references, reads callback properties, and triggers interactions. Callback readers accept Objects, including Instances; enumeration and reference functions use Instances.
Enumeration
getinstances
getinstances(): {Instance}getinstances returns the live Instances tracked by the client’s Lua instance cache.
Also available as get_instances, getinstancecache and get_instance_cache.
Returns
{Instance}An array of cached live Instances.
getnilinstances
getnilinstances(): {Instance}getnilinstances returns cached Instances whose Parent is nil.
Also available as get_nil_instances.
Returns
{Instance}An array of unique cached Instances with no parent.
getscripts
getscripts(excludeCore: boolean?): {LuaSourceContainer}getscripts returns cached LocalScripts, ModuleScripts, and Scripts configured to run on the client.
Also available as get_scripts.
Parameters
excludeCoreboolean??- Optional.Whether to omit descendants of CoreGui and CorePackages. Default
false.
Returns
{LuaSourceContainer}The cached client script objects.
getmodules
getmodules(excludeCore: boolean?): {ModuleScript}getmodules returns the ModuleScripts tracked by the client’s instance cache.
Also available as get_modules.
Parameters
excludeCoreboolean??- Optional.Whether to omit descendants of CoreGui and CorePackages. Default
false.
Returns
{ModuleScript}The cached ModuleScripts.
cloneref
cloneref(instance: Instance): Instance?cloneref creates a separate Lua reference to an Instance without duplicating the Instance itself.
Also available as clonereference, clone_ref, clone_reference, duplicateref and duplicate_ref.
Parameters
instanceInstance- The Instance for which to create another reference.
Returns
Instance?A new Lua reference to the same engine Instance, or no values if the Instance reference cache is unavailable.
compareinstances
compareinstances(first: Instance, second: Instance): booleancompareinstances returns whether two references point to the same Instance.
Also available as compare_instances.
Parameters
firstInstance- The first Instance reference to compare.
secondInstance- The second Instance reference to compare.
Returns
booleanTrue when both references identify the same Instance.
gethui
gethui(): Instance?gethui returns the UI container to which scripts can parent their interfaces.
Also available as get_hidden_ui and get_hidden_gui.
Returns
Instance?A distinct cached CoreGui reference, or nil when unavailable.
getcallbackvalue
getcallbackvalue(object: Object, property: string): any?getcallbackvalue returns the value assigned to an Object’s callback property, including properties that cannot normally be read.
Also available as get_callback_value.
Parameters
objectObject- The Object that owns the requested member.
propertystring- The name of the property to access.
Returns
any?The assigned callback value, or nil if no valid callback reference exists.
getcallbackthread
getcallbackthread(object: Object, property: string): thread?getcallbackthread returns the coroutine associated with an Object’s assigned callback.
Also available as get_callback_thread.
Parameters
objectObject- The Object that owns the requested member.
propertystring- The name of the property to access.
Returns
thread?The callback’s owning coroutine, or nil if its reference is no longer valid.
Example
firetouchinterest
firetouchinterest(first: BasePart, second: BasePart, state: number | boolean): ()firetouchinterest reports the beginning or end of a touch between two BaseParts.
Also available as fire_touch_interest.
Parameters
firstBasePart- The first BasePart in the touch transition.
secondBasePart- The second BasePart in the touch transition.
statenumber | boolean- 0 or false for touch; 1 or true for untouch.
Returns
()This function returns no values.
fireproximityprompt
fireproximityprompt(prompt: ProximityPrompt): ()fireproximityprompt activates a ProximityPrompt.
Also available as fire_proximity_prompt.
Parameters
promptProximityPrompt- The ProximityPrompt to activate.
Returns
()This function returns no values.
fireclickdetector
fireclickdetector(detector: ClickDetector, distance: number?, event: string?): ()fireclickdetector sends a click or hover interaction to a ClickDetector as the local player.
Also available as fire_click_detector.
Parameters
detectorClickDetector- The ClickDetector that receives the interaction.
distancenumber??- Optional.The distance passed with the click interaction. Default
0. eventstring??- Optional.mouseclick, rightmouseclick, mousehoverenter, or mousehoverleave; case-insensitive. Default
"mouseclick".
Returns
()This function returns no values.
SaveInstance
The SaveInstance API exports client-available objects as model or place files in binary or XML format. Saving yields until the output is written and verified; a failed save raises an error.
saveinstance
Yieldssaveinstance(root: (Instance | {Instance} | SaveOptions | string)?, options: (SaveOptions | string)?, filepath: string?): string?saveinstance saves client-available Instances to a model or place file.
Also available as save_instance and synsaveinstance.
Parameters
root(Instance | {Instance} | SaveOptions | string)??- Optional.An Instance or dense array to save; omit to save game. A SaveOptions table or output filepath within the workspace can also be passed first.
options(SaveOptions | string)??- Optional.SaveOptions for an explicit root, or an output filepath within the workspace after a root or options table.
filepathstring??- Optional.The output path within the workspace, overriding FilePath in options.
Returns
string?The output path within the workspace. Clipboard mode returns no values.
Example
savegame
Yieldssavegame(options: (SaveOptions | string)?, filepath: string?): string?savegame saves the current DataModel to a place file.
Also available as save_game.
Parameters
options(SaveOptions | string)??- Optional.SaveOptions controlling the save, or an output filepath within the workspace passed first.
filepathstring??- Optional.The output path within the workspace, overriding FilePath in options.
Returns
string?The place output path within the workspace. Clipboard mode returns no values.
SaveOptions
Option names are case-insensitive and unknown names are ignored. Use one spelling per option: supplying several aliases for the same field has no defined precedence. Mode has no effect. The available options and their aliases are listed below.
Decompilation deadlines
DecompileTimeout and ScriptTimeout both default to 10 seconds. DecompileTimeout applies to the captured-bytecode batch, which can run alongside property capture. It does not limit instance traversal, property capture, file encoding, writing, or verification. Each bytecode request receives the shorter of ScriptTimeout and the remaining batch budget; waiting for a worker uses that same request deadline.
Set DecompileTimeout to -1 to remove the batch deadline while retaining the per-request ScriptTimeout. A value of 0 starts with an expired batch deadline, so no new bytecode requests are started. When a script times out, the export continues with successful results from other scripts. It keeps an existing readable Source when available; otherwise that script's Source contains a failure comment.
A timeout releases the result wait and allows export progress to continue. Native calls already running can finish in the background and retain their worker slots until cleanup, so concurrency remains bounded.
Save progress
The save overlay reports the current phase. During decompilation it shows completed and total script counts, active and total worker counts, failures, and an active script's label or reference with elapsed time and its request limit in seconds. Timed-out scripts count as completed failures; the export can then proceed to encoding, writing, and verification.
Output behavior
Without FilePath, a place uses its PlaceId as the filename and a model uses saveinstance_model. A missing extension becomes .rbxl, .rbxlx, .rbxm, or .rbxmx according to the output type. Place exports omit CoreGui and CorePackages service roots and cannot include server-only data unavailable to the client. The output file is verified before its filename is returned.
Written for Lynx 0.747
Something unclear? Tell us on Discord