Garry's Mod Wiki

RunString

  string RunString( string code, string identifier = "RunString", boolean handleError = true )

Description

Evaluates and executes the given code, will throw an error on failure.

Local variables are not passed to the given code.

Arguments

1 string code
The code to execute.
2 string identifier = "RunString"
The name that should appear in any error messages caused by this code.
3 boolean handleError = true
If false, this function will return a string containing any error messages instead of throwing an error.

Returns

1 string
If handleError is false, the error message (if any).

Example

Compiles and runs print("test").

RunString([[print("test")]])
Output: test