---
name: "setFSMVariable"
type: command
status: ok
groups: ["System"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/setFSMVariable
revid: 330070
updated: 2022-08-15T16:49:43Z
---

# setFSMVariable

*Command · System · Arma 3 v0.50 · introduced in Arma 2 v1.00*

## Description

Set variable to given value in the variable space of given FSM.

The FSM handle is the number returned by the [execFSM](../commands/execFSM.md) command.

## Syntax

```sqf
handle setFSMVariable [name, value]
```

**Parameters:**

- `handle`: [Number](../topics/Number.md) - FSM handle
- `name`: [String](../topics/String.md) - name of the FSM variable
- `value`: [Anything](../topics/Anything.md) - new value of the FSM variable

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
_handle = execFSM "test.fsm";
_handle setFSMVariable ["_foo", 23]; // sets variable _foo in the FSM to 23
```

## See also

FSM · [commandFSM](../commands/commandFSM.md) · [completedFSM](../commands/completedFSM.md) · [doFSM](../commands/doFSM.md) · [execFSM](../commands/execFSM.md) · [getFSMVariable](../commands/getFSMVariable.md)

## Community notes

**Master85** — 2014-03-23

If the variable is not yet defined within the FSM it will be created.

<sub>Source: [BI Community Wiki — setFSMVariable](https://community.bistudio.com/wiki/setFSMVariable) (revision 330070).</sub>
