Read scripts
script_readReads Luau script source from Roblox Studio, including unsaved editor changes, and returns line numbers for precise edits. Use it to inspect current code before modifying scripts.
Instructions
Reads Luau source from one or more scripts, with line numbers that script_edit accepts back verbatim.
Source comes from the Studio script editor's live buffer, so anything the user has typed but not yet saved is included. Reading the saved property instead would hand you stale code and you would 'fix' the change they just made.
Pass every script you need in one call, including when you want a different part of each: an entry may be a bare path for the whole file, or {path, startLine, endLine} for a window into that one script. The top-level startLine/endLine are the default for entries that do not carry their own.
A script bound to a file on disk is flagged in the result. Editing one of those is a race: whatever writes the file wins, and your change disappears the next time it does, with nothing anywhere reporting a failure.
open puts a script on the user's screen at a line, instead of telling them where to look. Ask for it when you are pointing at something they should see; it is not automatic, and reading twenty scripts does not rearrange their editor.
target="live" reads the code of the PUBLISHED place instead, with no Studio involved — which is how you check what is actually deployed rather than what is on someone's machine. Two limits are real and worth knowing before you reach for it: Roblox's Instance API can only see Folders and scripts, so a path through a Model or a Part cannot be walked at all; and it addresses things by GUID with no search, so each segment of the path costs a round trip. Expect seconds. list: true shows what is under a path instead of reading it, which is how you find your way down.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | No | 'read' returns source. 'open' opens the first path in the user's Studio editor at `line` and returns nothing to read. | read |
| line | No | open only: line to put the cursor on. | |
| list | No | live only: list what is under the first path instead of reading it. Pass an empty path list to see the top level. | |
| paths | Yes | Scripts to read, e.g. ["ServerScriptService.Systems.Combat"] or [{ path: "...Combat", startLine: 120, endLine: 180 }]. | |
| target | No | 'studio' reads the open place. 'live' reads the published place over Open Cloud, Folders and scripts only. | studio |
| endLine | No | Default last line for entries without their own, inclusive. Omit to read to the end. | |
| placeId | No | live only: omit to use `cloud place`. | |
| studioId | No | Target Studio; omit for the active one. | |
| startLine | No | Default first line for entries without their own, 1-based and inclusive. Omit to start at the top. | |
| universeId | No | live only: omit to use `cloud universe`. |