Description
Executes Luau code in edit mode (not during play mode). Captures print, warn, and error output, and returns the result of the execution. Useful for quick scripts, debugging, and automation tasks.
Endpoint
Parameters
Response
Returns true if the code executed successfully
The return value of the executed code, serialized to JSON-compatible format
Array of captured output strings from print, warn, and error calls
Error message if compilation or execution failed
Captured output is prefixed with:
[OUTPUT] - from print() calls
[WARNING] - from warn() calls
[ERROR] - from error() calls
Examples
Simple calculation
{
"code": "return 2 + 2"
}
Response:
{
"ok": true,
"result": 4,
"output": []
}
Create a part
{
"code": "local part = Instance.new('Part')\npart.Parent = workspace\npart.Position = Vector3.new(0, 10, 0)\nreturn part.Name"
}
Response:
{
"ok": true,
"result": "Part",
"output": []
}
With print output
{
"code": "print('Starting...')\nlocal sum = 0\nfor i = 1, 10 do sum = sum + i end\nprint('Done')\nreturn sum"
}
Response:
{
"ok": true,
"result": 55,
"output": [
"[OUTPUT] Starting...",
"[OUTPUT] Done"
]
}
Return table data
{
"code": "return { players = 5, maxPlayers = 10, gameMode = 'Deathmatch' }"
}
Response:
{
"ok": true,
"result": {
"players": 5,
"maxPlayers": 10,
"gameMode": "Deathmatch"
},
"output": []
}
Compilation error
Response:
{
"error": "Compile error: ..."
}
Runtime error
{
"code": "error('Something went wrong')"
}
Response:
{
"error": "Runtime error: Something went wrong",
"output": ["[ERROR] Something went wrong"]
}