Skip to main content

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

Retrieves the complete source code of a script (LuaSourceContainer) and returns it along with the line count.

Endpoint

get_script_source

Parameters

path
string
required
The path to the script instance in the DataModel tree

Response

Success Response

source
string
The complete source code of the script
lineCount
number
The total number of lines in the script

Error Response

error
string
Error message if the operation failed. Possible errors:
  • Path resolution failure
  • “Cannot read source (may require plugin permissions)”
  • is not a script”

Implementation Details

  • Only works with instances that inherit from LuaSourceContainer (Script, LocalScript, ModuleScript)
  • Line count is calculated by counting newline characters plus 1
  • Requires plugin permissions to read script sources
  • Uses pcall to safely access the Source property

Examples

Basic Usage

local result = ScriptTools.get_script_source({
  path = "game.ServerScriptService.MainScript"
})

if result.error then
  print("Error:", result.error)
else
  print("Source length:", #result.source)
  print("Line count:", result.lineCount)
end

Reading a ModuleScript

local result = ScriptTools.get_script_source({
  path = "game.ReplicatedStorage.Modules.PlayerData"
})

if result.source then
  -- Process the source code
  local lines = result.source:split("\n")
  for i, line in ipairs(lines) do
    print(i, line)
  end
end