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

Replaces the complete source code of a script (LuaSourceContainer) with new content.

Endpoint

set_script_source

Parameters

path
string
required
The path to the script instance in the DataModel tree
source
string
required
The new source code to set for the script

Response

Success Response

ok
boolean
Returns true if the operation was successful

Error Response

error
string
Error message if the operation failed. Possible errors:
  • Path resolution failure
  • “Not a script”
  • Error from setting the Source property

Implementation Details

  • Only works with instances that inherit from LuaSourceContainer (Script, LocalScript, ModuleScript)
  • Completely replaces the existing source code
  • Requires plugin permissions to write script sources
  • Uses pcall to safely set the Source property
  • Any existing content will be overwritten

Examples

Basic Usage

local newSource = [[
local function hello()
  print("Hello, World!")
end

hello()
]]

local result = ScriptTools.set_script_source({
  path = "game.ServerScriptService.TestScript",
  source = newSource
})

if result.error then
  print("Error:", result.error)
else
  print("Source updated successfully")
end

Updating a ModuleScript

local moduleSource = [[
local Module = {}

function Module.new()
  return setmetatable({}, { __index = Module })
end

return Module
]]

local result = ScriptTools.set_script_source({
  path = "game.ReplicatedStorage.MyModule",
  source = moduleSource
})

if result.ok then
  print("Module updated")
end

Clearing a Script

local result = ScriptTools.set_script_source({
  path = "game.ServerScriptService.OldScript",
  source = "" -- Empty script
})