Skip to main content

Overview

Read the source code of a Roblox script (LocalScript, Script, or ModuleScript) with line numbers for precise editing. Returns both raw source and numbered source for easy line identification.
For large scripts (>1500 lines), use startLine and endLine parameters to read specific sections and avoid performance issues.

Parameters

instancePath
string
required
Roblox instance path to the script using dot notationExamples:
  • game.ServerScriptService.MainScript
  • game.StarterPlayer.StarterPlayerScripts.LocalScript
  • game.ReplicatedStorage.Modules.DataManager
startLine
number
Start line number (1-indexed) for reading specific sections of large scriptsDefault: Read from beginning
endLine
number
End line number (inclusive) for reading specific sections of large scriptsDefault: Read to end

Response

{
  "source": "-- Main game script\nlocal Players = game:GetService('Players')\nprint('Game started')",
  "numberedSource": "1: -- Main game script\n2: local Players = game:GetService('Players')\n3: print('Game started')",
  "lineCount": 3
}
source
string
Raw script source code without line numbers
numberedSource
string
Script source with line numbers prefixed (format: lineNumber: code)Use this field to identify correct line numbers for editing operations
lineCount
number
Total number of lines in the script

Usage Examples

Read Entire Script

{
  "instancePath": "game.ServerScriptService.MainScript"
}

Read Specific Section (Large Scripts)

{
  "instancePath": "game.ServerScriptService.LargeScript",
  "startLine": 100,
  "endLine": 200
}

Example Workflow: Edit a Function

  1. Read script with line numbers:
{
  "instancePath": "game.ServerScriptService.PlayerHandler"
}
  1. Identify target lines from numberedSource:
45: local function onPlayerJoin(player)
46:     print('Player joined:', player.Name)
47: end
  1. Use line numbers for editing (see edit_script_lines)

Best Practices

When planning to edit, insert, or delete lines, always reference the numberedSource field to identify correct line numbers. The line numbers are 1-indexed and match exactly what the editing tools expect.
For scripts with >1500 lines, read specific sections using startLine and endLine to improve performance and reduce response size.
{
  "instancePath": "game.ServerScriptService.HugeScript",
  "startLine": 500,
  "endLine": 600
}
Always read the current source before making edits to ensure you’re working with the latest version and correct line numbers.
Works with all Roblox script types:
  • Script (ServerScript)
  • LocalScript
  • ModuleScript

Line Number Format

The numberedSource field uses this format:
1: -- First line of code
2: local variable = 'value'
3: 
4: function example()
5:     print('Hello')
6: end
  • Line numbers are 1-indexed (first line is 1, not 0)
  • Empty lines are counted and numbered
  • Line numbers are followed by : (colon and space)
  • All subsequent editing operations use these exact line numbers

set_script_source

Replace entire script source

edit_script_lines

Replace specific line ranges

insert_script_lines

Insert new lines at position

delete_script_lines

Delete line ranges

Error Handling

{
  "error": "Instance not found or is not a script",
  "instancePath": "game.ServerScriptService.NonExistent"
}

Build docs developers (and LLMs) love