Edit scripts
script_editApply batch edits to Luau scripts in Roblox Studio, ensuring all changes are applied atomically.
Instructions
Edits Luau source through the Studio script editor. This is the tool to use for any change to existing code.
Every edit in one call is all-or-nothing: the whole batch is resolved against current source before anything is written, so if one edit cannot be applied nothing is. Batch related changes together, even across different scripts.
Each edit picks exactly one mode:
find/replace — literal text, not a pattern. Preferred: it survives line numbers shifting. Fails if the text is not unique, unless you set replaceAll, so include enough surrounding lines to pin it down.
startLine/endLine + replacement — for line ranges from script_read. Numbers refer to the file as you read it; several line edits to one script are applied bottom-up so they do not shift each other.
source — replaces the whole script. Only for small files or a rewrite; it discards anything the user changed since you read it.
Writes go through ScriptEditorService:UpdateSourceAsync, so an open editor tab updates in place and unsaved work is preserved. Undo for source changes is the script editor's own, per script — Ctrl+Z in a script tab reverts that script, not the whole batch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | Yes | Edits to apply together as one undoable step. | |
| studioId | No | Target Studio; omit for the active one. |