loadstring
Compiles a string with the Luau compatibility pass applied. Like Roblox, syntax errors yield a function that raises the error when called.
Syntax
loadstring(source: string, chunkName?: string) -> function
Parameters
| Parameter | Type | Description |
|---|---|---|
source | string | Luau source code to compile or execute. |
chunkName? | string | The chunk name value used by the call. |
Returns
| Type | Description |
|---|---|
function | Function |
Description
loadstring is part of the Scripts & decompiling library. Script helpers inspect scripts in the live DataModel and can read bytecode or decompile source.
Each call creates or returns a fresh object or value that you can store and pass to other functions.
Example
local fn = loadstring("print('hello from a string')")
fn()
Notes
- Script bytecode and source are read from the live game.