A compartment for a vehicle is provided herein. The compartment includes a housing defining an interior volume. A lid is pivotably coupled to the housing and is configured to move between a closed position in which the interior volume is inaccessible and an open position in which the interior volume is accessible. A latch is configured to maintain the lid in a locked and an unlocked state when the lid is disposed in the closed position. A compartment sensing system is operably coupled with the latch. The latch is placed in the locked state when the sensing system detects the presence of an item within the interior volume.