Overview
Delete specific lines from a Roblox script without rewriting the entire source. Ideal for removing deprecated code, debug statements, or unused functions.Line numbers are 1-indexed and ranges are inclusive. Always use the
numberedSource field from get_script_source to identify correct line numbers.Parameters
Roblox instance path to the script using dot notationExamples:
game.ServerScriptService.MainScriptgame.StarterPlayer.StarterPlayerScripts.LocalScriptgame.ReplicatedStorage.Modules.DataManager
First line to delete (1-indexed)Get from
numberedSource field of get_script_sourceLast line to delete (inclusive)Get from
numberedSource field of get_script_sourceResponse
Whether the operation completed successfully
Status message describing the operation
Number of lines removed (endLine - startLine + 1)
Total lines remaining in script after deletion
Usage Examples
Delete Single Line
Before:Delete Entire Function
Before:Delete Multiple Debug Statements
Before:Delete Comment Block
Before:Best Practices
Always Read Before Deleting
Always Read Before Deleting
Step 1: Call Step 2: Identify lines to delete from Step 3: Delete using exact line numbers:
get_script_source to see current contentnumberedSource:Line Range is Inclusive
Line Range is Inclusive
startLine to endLine includes both endpoints:startLine: 5, endLine: 5→ deletes line 5 onlystartLine: 5, endLine: 7→ deletes lines 5, 6, and 7 (3 lines total)startLine: 10, endLine: 20→ deletes 11 lines total
Consider Surrounding Context
Consider Surrounding Context
Be careful when deleting lines that might affect surrounding code:Instead, delete the entire function (lines 14-17) or none at all.
Delete Blank Lines for Cleanup
Delete Blank Lines for Cleanup
Remove extra spacing for cleaner code:
Remove double blank
Validate Syntax After Deletion
Validate Syntax After Deletion
After deleting lines, verify the script is still valid:
Deletion Cannot Be Undone via MCP
Deletion Cannot Be Undone via MCP
Once lines are deleted through MCP, you cannot undo via MCP tools. However:
- Roblox Studio’s built-in Undo (Ctrl+Z) may still work
- Consider reading and backing up the source before major deletions
- For testing, use a copy of the script first
Common Patterns
Remove All Debug Print Statements
Step 1: Find debug
Step 2: Delete each debug line
Remove Deprecated Function
Delete old function and its comments
Clean Up Old Comments
Remove outdated TODO comments
Remove Entire Code Block
Delete conditional block no longer needed
Related Tools
get_script_source
Read script with line numbers
set_script_source
Replace entire script
edit_script_lines
Replace specific line ranges
insert_script_lines
Insert new lines
Error Handling
Complete Workflow Example
Step 1: Read current source
Step 2: Identify to remove
Step 3: Delete old function
Step 4: Result
Safety Checklist
Before deleting lines, verify:- Read the script and confirmed line numbers from
numberedSource - Identified the correct
startLineandendLine - Checked that deletion won’t break surrounding code
- Considered whether to also delete blank lines above/below
- Have a way to recover if needed (Studio Undo, version control, backup)