> For the complete documentation index, see [llms.txt](https://oph3zdev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oph3zdev.gitbook.io/docs/paid-scripts/inventory/statebags.md).

# Statebags

Statebags are small flags stored on the player that any resource can read or change through `LocalPlayer.state`. The inventory keeps them updated and reacts when another script changes them - no exports or events needed. Usage is identical to ox\_inventory, so scripts written for its statebags work without editing.

### invBusy

Tells you whether the inventory is currently running an action (like eating or drinking). You can also set it to `true` yourself to block the player from opening the inventory and using hotbar keys - useful during cutscenes, minigames or being cuffed.

```lua
if LocalPlayer.state.invBusy then
    -- The player is busy
end
```

Block opening the inventory:

```lua
LocalPlayer.state.invBusy = true
```

### invHotkeys

Set to `false` to disable the hotbar keys (1-6) and the quick slot peek key. The inventory open key keeps working - use `invBusy` if you want to block that too.

```lua
LocalPlayer.state.invHotkeys = false
```

### invOpen

Tells you whether the inventory is open right now. Read only - the inventory sets it when opening and closing.

```lua
if LocalPlayer.state.invOpen then
    -- The inventory is open
end
```

### instance

Puts the player in a separate "world" for ground drops - for example inside a property or an arena. Drops created there are only visible to players in the same instance, and players outside can not see or open them. Set it to `nil` to return to the normal world.

The third argument (`true`) is required - it sends the value to the server, which needs it to keep drops separated.

```lua
LocalPlayer.state:set("instance", "property_1", true)
LocalPlayer.state:set("instance", nil, true)
```

It can also be set from the server side:

```lua
Player(source).state:set("instance", "property_1", true)
```

### canUseWeapons

Set to `false` to block the player from equipping weapons. If a weapon is already in their hands, it is holstered right away with its ammo saved. Set it back to `true` to allow weapons again.

```lua
LocalPlayer.state.canUseWeapons = false
```
