Skip to content


Function info

function LuauInLuau.CreateClosureFromSource(src: string, safeenv: boolean?, optimizationlevel: number?, debuglevel: number?): () -> ()

Compiles Luau source into a closure


  • src: string - The source
  • safeenv: boolean? - Indicates whether safeenv features should be enabled or not
  • optimizationlevel: number? - The optimization level for the resulting bytecode
  • debuglevel: number? - The debug level for the resulting bytecode

Important note regarding the optimization and debug level arguments

The optimizationlevel and debuglevel argument is only available starting with LuauInLuau v0.579