Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nnaridz/RbxGenie/llms.txt
Use this file to discover all available pages before exploring further.
Description
Deletes a specified range of lines from a script. The start and end lines are inclusive.
Endpoint
delete_script_lines
Parameters
The path to the script instance in the DataModel tree
The first line number to delete (1-indexed, inclusive)
The last line number to delete (1-indexed, inclusive)
Response
Success Response
Returns true if the operation was successful
The total number of lines in the script after deletion
The number of lines that were deleted
Error Response
Error message if the operation failed. Possible errors:
- Path resolution failure
- Script read errors
- Error from setting the Source property
Implementation Details
- Line numbers are 1-indexed (first line is 1)
- Start and end lines are clamped to valid ranges (1 to total lines)
- Both start and end lines are inclusive
- Lines outside the specified range are preserved
- Remaining lines maintain their relative order
Examples
Delete a Single Line
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 5,
endLine = 5
})
if result.ok then
print("Deleted", result.deletedLines, "line(s)")
print("New line count:", result.lineCount)
end
Delete Multiple Lines
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 10,
endLine = 20
})
if result.ok then
print("Deleted lines 10-20 (" .. result.deletedLines .. " lines)")
end
Delete from Beginning
-- Delete the first 3 lines (e.g., old header comments)
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 1,
endLine = 3
})
Delete to End
-- First, get the line count
local source = ScriptTools.get_script_source({
path = "game.ServerScriptService.MainScript"
})
if source.lineCount then
-- Delete from line 50 to the end
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 50,
endLine = source.lineCount
})
end
Remove a Function
-- Delete lines 25-35 which contain an old function
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 25,
endLine = 35
})
if result.error then
warn("Failed to delete:", result.error)
else
print("Function removed successfully")
end
Safe Deletion with Bounds
-- The implementation automatically clamps to valid ranges
-- This will only delete up to the last line even if endLine is larger
local result = ScriptTools.delete_script_lines({
path = "game.ServerScriptService.MainScript",
startLine = 100,
endLine = 999999 -- Will be clamped to actual line count
})