# llSetScriptState

*LSL function*

```lsl
void llSetScriptState(string script, integer running);
```

- `string script`: Name of the script in the prim's inventory.
- `integer running`: Boolean. If TRUE, enables the script; if FALSE, disables it.

- Energy: 10

Sets the running state of the named script in the prim's inventory. If running is TRUE, the script is enabled; if FALSE, it is disabled.

Set the running state of the script `name`.

```lsl title="How to use" frame="terminal"
llSetScriptState("", 0);
```

## Caveats

- Cannot be used to restart a script that has encountered a [run-time error](https://wiki.secondlife.com/wiki/Category:LSL_Error).
- Cannot be used to start a script that has been added via [llGiveInventory](/functions/llGiveInventory/). Scripts sent via [llRemoteLoadScriptPin](/functions/llRemoteLoadScriptPin/), and which have the running state set [FALSE](/constants/FALSE/) by that command, may be started.
- The script appears to stop when its time slice ends, not sooner. If a script tries to stop itself then some LSL code following the `llSetScriptState` call may be executed before the script stops.
- If a script is paused by `llSetScriptState` and is then either re-rezzed, in a region during a restart, or moved into a different region, the script's memory is reset.

## Examples

<details open>
<summary>Example 1</summary>

```lsl
//Stops the Script, at some non-deterministic time later, until invoked with TRUE, in another script
llSetScriptState(llGetScriptName(),FALSE);
// Stall until end of time slice
llSleep(0.1);
```

</details>

<details>
<summary>Example 2</summary>

```lsl
//Starts Another Script
llSetScriptState("somescript",TRUE);
```

</details>

## Known issues

From the issue templates included by the wiki article:

- SVC-1853 (bug): Scripts deactivated by llSetScriptState are reset when the region is reset, when they are taken into inventory and re-rezzed and when crossing sim boundaries.

## See also

### Functions

- [llGetScriptState](/functions/llGetScriptState/)
- [llResetOtherScript](/functions/llResetOtherScript/)

---

*Source: [LlSetScriptState](https://wiki.secondlife.com/wiki/LlSetScriptState) on the Second Life Wiki. Content from the Second Life Wiki articles LlSetScriptState (revision 1194424, 2015-01-22), Template:Issues/SVC-1853 (revision 1155886, 2011-10-18), Template:LSL Function/inventory (revision 1191151, 2014-06-07) and Template:LSL Function/boolean (revision 1185613, 2013-12-24), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llSetScriptState/
