edit_script
Surgical find-and-replace inside an existing script — not a full rewrite.
What it does
edit_script is the primary way Revix modifies script source. You give it a path, an old_text snippet that must match the script exactly once, and a new_text to replace it with. If the match is ambiguous (matches more than once) or missing (matches zero times), the tool errors and Revix has to try again with more context.
Whitespace, indentation, and line breaks all matter — the match is exact. Revix always calls read_script first to ground the snippet in the real source, and re-reads after each edit because previous reads become stale.
This is intentionally not a rewrite tool. For small, targeted changes — adding a parameter, fixing a bug, inserting a block — edit_script keeps diffs small and reviewable.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| `path` | string | yes | DataModel path to the script. |
| `old_text` | string | yes | Exact text to find. Must match exactly once including whitespace. |
| `new_text` | string | yes | Text to replace it with. |
When Revix uses it
- Fixing a bug in an existing script
- Adding a new function, branch, or parameter without rewriting the file
- Renaming a variable that appears in one specific location
- Inserting a require, listener, or guard clause
Example
-- old_text
local function spawnPlayer(player)
player.Character:MoveTo(Vector3.new(0, 5, 0))
end
-- new_text
local function spawnPlayer(player, position)
position = position or Vector3.new(0, 5, 0)
player.Character:MoveTo(position)
endTroubleshooting
If you see repeated "old_text matched zero times" or "matched more than once" errors, the script changed between the read and the edit. See editing scripts for the read-edit cycle and tips on uniqueness.