---
name: "deleteGroupWhenEmpty"
type: command
status: ok
groups: ["Groups"]
arma3_since: "1.68"
locality: {"argument": "local", "effect": "global", "server_exec": false}
source: https://community.bistudio.com/wiki/deleteGroupWhenEmpty
revid: 353027
updated: 2024-03-12T11:37:47Z
---

# deleteGroupWhenEmpty

*Command · Groups · Arma 3 v1.68*

Locality: arguments **local** · effect **global**

## Description

Marks given group for auto-deletion when group is empty.
[true](../commands/true.md) will mark the group for auto-deletion once empty, [false](../commands/false.md) will simply unmark the group that was marked previously.

> [!IMPORTANT]
> This command does **not** prevent group deletion (through e.g [deleteGroup](../commands/deleteGroup.md) or any engine group management).

## Syntax

```sqf
group deleteGroupWhenEmpty delete
```

**Parameters:**

- `group`: [Group](../topics/Group.md)
- `delete`: [Boolean](../topics/Boolean.md) - [true](../commands/true.md) to mark for auto-deletion on empty group, [false](../commands/false.md) to not use this auto-deletion system

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

## Examples

### Example 1

```sqf
_group deleteGroupWhenEmpty true;
```

### Example 2

Executed on the server:

```sqf
if (local _group) then
{
    _group deleteGroupWhenEmpty true;
}
else // group is local to a client
{
    [_group, true] remoteExec ["deleteGroupWhenEmpty", groupOwner _group];
};
```

## See also

[deleteGroup](../commands/deleteGroup.md) · [isGroupDeletedWhenEmpty](../commands/isGroupDeletedWhenEmpty.md) · [createGroup](../commands/createGroup.md) · [group](../commands/group.md) · [setGroupId](../commands/setGroupId.md) · groupID · [units](../commands/units.md) · [groupFromNetId](../commands/groupFromNetId.md) · [netId](../commands/netId.md) · [leader](../commands/leader.md) · [selectLeader](../commands/selectLeader.md) · [join](../commands/join.md) · [createCenter](../commands/createCenter.md) · [createUnit](../commands/createUnit.md) · [createVehicle](../commands/createVehicle.md) · [Side](../topics/Side.md)

## Community notes

**PierreMGI** — 2023-12-01

The auto-deletion of a group is not automatic. For example, if you place a group in editor, name it (grp1), and kill the units in preview, this group remains not null and is counted as group (checked by count allGroups).
On the other hand, if you write: `this deleteGroupWhenEmpty true` in composition init (group init), this group will become null sometimes after the units are killed. It takes a little time for dead units to exit the group, then an extra time for the group to be deleted once all units dead. (count allGroups decreases).
Of course, in both cases, grp1 remains a variable ("grp1" is not nil).

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