# Sandbox.BaseInventoryComponent.GetBestItem

```csharp
BaseInventoryItem GetBestItem()
```

Returns the highest [Sandbox.BaseInventoryItem.Value](/api/Sandbox.BaseInventoryItem/Value) item we're allowed to switch to, or
null if there's nothing switchable. Items flagged [Sandbox.BaseInventoryItem.ShouldAvoid](/api/Sandbox.BaseInventoryItem/ShouldAvoid)
(e.g. empty guns) are only picked when nothing better exists. Override for game-specific
priority - runs on the host for engine-driven switches (remove, drop, pickup, loadout), so
per-player preference data must be host-available.

### Returns

`BaseInventoryItem`

Declared in [Sandbox.BaseInventoryComponent](/api/Sandbox.BaseInventoryComponent).
Assembly: `Sandbox.Engine`.
