Scan connection handlers by defining script source
scan-connections-by-sourceScan a Roblox instance hierarchy to find Lua event handlers and pinpoint which script defines each connection, filtered by source pattern.
Instructions
Sweep a hierarchy for event handlers and pinpoint which script each handler is defined in. Walks descendants of root, probes a set of signal names on each instance, and for every Lua connection describes its Function via debug.info. If the function's Source contains sourcePattern (case-insensitive substring; empty matches ALL handlers) it records { Instance, Signal, ConnectionIndex, Source, LineDefined, Name }. This answers "find every event handler defined in ", "where are all the handlers backed by this module?", or simply "enumerate all connected handlers under here and tell me their source". Requires the executor's getconnections and debug.info; degrades to a clear { error } if getconnections is unavailable (a missing debug.info merely leaves Source blank). Bounded by maxScan (instances) and maxResults (matches). Returns { Matches, MatchCount, ScannedInstances, Truncated }. Signature: { root: any?, sourcePattern: any?, signalNames: any?, maxResults: any?, maxScan: any?, threadContext: number? }. Phase: observe; cost=high; idempotency=read-only. Requires: active-client. Capabilities: getconnections. Produces: bounded-candidates, created-handle. Safety: read-only. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| root | No | Lua expression for the root instance whose descendants are scanned (e.g. 'game', 'game.Workspace', 'game.StarterGui'). Evaluated as `return <root>`. Defaults to 'game'. Narrow this to speed up the scan and reduce noise. | game |
| maxScan | No | Maximum number of descendant instances to examine. Defaults to 4000. Raise to cover larger games (slower); lower for a quick sample. If this cap is hit, Truncated is true. | |
| maxResults | No | Maximum number of matching connections to collect before stopping the scan. Defaults to 200. If this cap is hit, Truncated is true. | |
| signalNames | No | Signal member names to probe on each instance. When omitted, a sensible default list of commonly connected signals is used (Touched, Changed, ChildAdded, Activated, InputBegan, OnClientEvent, Heartbeat, etc.). Provide your own list to target specific events and make the scan faster. | |
| sourcePattern | No | Case-insensitive substring matched against each Lua connection's function Source (the chunk/script path reported by debug.info, e.g. a script name or asset path). When empty (default), EVERY Lua handler is matched, giving a full inventory. Set it to a script name to find only handlers defined in that script. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |