# Sandbox.ScriptSystem

Creates scripts in the current menu or game context. Identical source shares cached code,
while each script has independent arguments and execution state.

- Kind: class
- Namespace: `Sandbox`
- Assembly: `Sandbox.Engine`
- Modifiers: sealed

## Properties

- [`Globals`](/api/Sandbox.ScriptSystem/Globals): Runtime values shared by all scripts in this game or menu context.

## Methods

- [`Analyze`](/api/Sandbox.ScriptSystem/Analyze)
- [`CreateScript`](/api/Sandbox.ScriptSystem/CreateScript): Creates a reusable script. Syntax and execution errors are reported through [Sandbox.Script.LastError](/api/Sandbox.Script/LastError). Binding and IL compilation occur on the first run, once arguments are available. Supply a local store to share persistent fields or preserve them across source edits. If omitted, the script receives its own local store.
- [`CreateStore`](/api/Sandbox.ScriptSystem/CreateStore): Creates an independent store. Share it between scripts belonging to the same owner.
- [`Run`](/api/Sandbox.ScriptSystem/Run): Runs a script using cached code and returns its value. Throws if execution fails, no value is returned, or the return type is incompatible with `T`.
