loadstring
Compiles and loads a string of Luau source code at executor-level identity.
function loadstring(sourcesourcestringThe Luau source code to compile.: string, chunknamechunknamestring?Name used in error stack traces.: string?): (function?, string?)function?The compiled function, or nil on error.string?The compilation error message if compilation failed.Usage
Dynamic execution
local fn, err = loadstring("return 1 + 1")
if fn then
print(fn()) --> 2
else
warn("Compile error:", err)
end