---
name: "private"
type: command
status: ok
groups: ["Variables"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/private
revid: 377850
updated: 2026-01-03T11:40:32Z
---

# private

*Command · Variables · Arma 3 v0.50 · introduced in Operation Flashpoint v1.00*

## Description

Sets a variable to the innermost scope. See also [param](../commands/param.md) and [params](../commands/params.md).

> [!WARNING]
> - [private](../commands/private.md) variables **must** start with an underscore:  - see [Identifier](../topics/Identifier.md).
> - **Always** make your local variables **private** (through [private](../commands/private.md) or [params](../commands/params.md)) in order to avoid [overwriting a local variable of the same name](../topics/Variables.md#scopes).

## Syntax

### Syntax 1

```sqf
private variableName
```

**Parameters:**

- `variableName`: [String](../topics/String.md) - e.g `"_myVar"`

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

### Syntax 2

```sqf
private variableNameList
```

**Parameters:**

- `variableNameList`: [Array](../topics/Array.md) of [String](../topics/String.md)s - e.g `["_target", "_damage"]`

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

### Syntax 3

*since arma3 1.54*

```sqf
private _identifier = value From Arma 2 v1.00 to Arma 3 v1.52: see local
```

**Parameters:**

- `_identifier`: underscored [variable name](../topics/Identifier.md), for example `_myVar`
- `value`: [Anything](../topics/Anything.md): value to assign to the variable

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

## Examples

### Example 1

```sqf
private _varname = "this is my new variable"; // since Arma 3 v1.54

// identical, but less performant
private "_varname";
_varname = "this is my new variable";
```

### Example 2

```sqf
private ["_varname1", "_varname2"];
_varname1 = "variable 1";
_varname2 = "variable 2";
```

### Example 3

```sqf
_lol = 123; call { hint str [_lol] }; // [123]
_lol = 123; call { private "_lol"; hint str [_lol] }; // [any]
```

### Example 4

```sqf
_myvar = 123;
systemChat str [_myvar];        // [123]
call {
    systemChat str [_myvar];    // [123]
    private "_myvar";
    systemChat str [_myvar];    // [any]
    _myvar = 345;
    systemChat str [_myvar];    // [345]
};
systemChat str [_myvar];        // [123]
```

## See also

[param](../commands/param.md) · [params](../commands/params.md) · [privateAll](../commands/privateAll.md)

## Community notes

**Faguss** — 2010-08-04

The higher scope is also the script from which the function has been called.

in **script2.sqf**:

```sqf
_a = 2;
```

in **script1.sqf**:

```sqf
_a = 1;
call compile preprocessFileLineNumbers "script2.sqf";
hint format ["%1", _a];
```

Game will display 2.

Inserting `private "_a"` in the function prevents the change and so number 1 will be displayed on the screen.

---

**DreadedEntity** — 2015-02-25

Recursive loops require the use of [private](../commands/private.md). Without it, your variables will be overwritten.

---

**654wak654** — 2018-01-31

This command is *similar* to javascript's [let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) keyword.

**EDIT:** in the way that it scopes the variable to the innermost scope. Otherwise, let and private can behave differently - Lou Montana (talk)

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