FiveM Door Lock Script Guide: Securing Interiors for QBCore & ESX (2026)
How door lock scripts work in FiveM, setup guides for popular options like ox_doorlock and qb-doorlock, configuring permissions by job and item, and troubleshooting common issues.
What Is a Door Lock Script?
A door lock script controls who can open and close doors throughout your FiveM server. Without one, every door in the game world is either permanently open or permanently closed at its default state. Door scripts let you:
- Lock police station doors so only officers can enter
- Lock business interiors to job-specific employees
- Create key-based access for housing
- Allow criminals to lockpick secured locations
- Control access to restricted areas (jail, government buildings, VIP zones)
Door locks are one of the most fundamental scripts on any RP server. They are required by many other scripts (housing, jobs, businesses) as a dependency.
How Door Lock Scripts Work
GTA V Door System
GTA V has built-in door entities that can be controlled via natives:
- DoorSystemSetDoorState â Lock or unlock a door by its hash
- DoorSystemSetAutomaticRate / DoorSystemSetAutomaticDistance â Control auto-open behavior
Each door in GTA V has a model hash and exists at specific coordinates. Door lock scripts identify doors by their hash + coordinates combination.
Door Identification
Finding the correct door hashes is one of the most tedious parts of FiveM development. Methods include:
- In-game debug tools â Scripts that display the model hash of the nearest door
- Door hash databases â Community-maintained lists of common door hashes organized by location
- Raycast detection â Point at a door and the script reads its entity info
Lock States
| State | Behavior |
|---|---|
| Unlocked | Any player can open the door normally |
| Locked | Door cannot be opened (solid, immovable) |
| Restricted | Only authorized players can open it (job, item, or key-based) |
| Auto-lock | Door relocks after a configurable time period |
Popular Door Lock Scripts
ox_doorlock (Overextended)
ox_doorlock is the most widely used door lock system in 2026. Key features:
- Framework agnostic â Works with ESX, QBCore, and standalone setups via ox_lib
- In-game editor â Create and configure new door locks directly in-game without editing config files
- Permission types â Lock by job, job grade, item, citizenid/license, or group
- Auto-lock â Doors re-lock after a configurable delay
- Lockpick support â Integration with lockpicking scripts
- Double doors â Supports paired doors that open/close together
- Performant â Optimized with minimal resource usage
The in-game editor is the standout feature: point at a door, run a command, and define its lock settings through a menu â no server restart needed.
qb-doorlock
The default door lock system for QBCore servers:
- QBCore-native â Uses QBCore exports and player data directly
- Config-based â Doors are defined in a config file with coordinates, hashes, and permissions
- Job restrictions â Lock doors by job name and minimum grade
- Item restrictions â Require a specific item (key card, key) to unlock
- Shared keys â Multiple players can have access to the same door
The main limitation is config-based setup â every door must be added manually to the config file with its exact hash and coordinates.
esx_doorlock
The ESX equivalent, offering similar functionality: config-based door definitions, ESX job-based permissions, and event-driven lock/unlock system.
Setup Guide: ox_doorlock (Recommended)
Prerequisites: ox_lib installed, oxmysql for database storage.
Installation Steps:
- Download ox_doorlock from GitHub
- Place in resources folder
- Import the SQL file into your database
- Add ensure ox_doorlock to server.cfg (after ox_lib and oxmysql)
- Grant admin permissions for the in-game editor
Adding Doors In-Game:
- Navigate to the door you want to lock
- Open the admin menu (configured command)
- The script auto-detects the nearest door and its hash
- Set permissions â choose job, grade, item, or ACE group requirements
- Configure auto-lock (optional)
- Save â the door is now locked and persisted in the database
Common Configuration Patterns
Police Station
Lock all PD doors to police job, with different grades for different areas:
| Area | Required Job | Minimum Grade | Reason |
|---|---|---|---|
| Front entrance | police | 0 (any rank) | General access |
| Armory | police | 2 (Sergeant+) | Restrict weapon access |
| Evidence room | police | 3 (Lieutenant+) | Sensitive materials |
| Chief's office | police | 4 (Chief only) | Private office |
Hospital
| Area | Access | Method |
|---|---|---|
| Main entrance | Everyone | Unlocked always |
| Staff areas | ambulance job | Job restriction |
| Pharmacy | ambulance grade 2+ | Grade restriction |
| Morgue | ambulance or police | Multi-job restriction |
Business Interiors
For player-owned businesses, use item-based locks (business key) or citizenid locks (owner identifier) rather than job locks.
Lockpicking Integration
Door lock scripts usually support lockpicking for criminal gameplay:
- A player uses a lockpick item on a locked door
- A minigame starts (timing-based, skill check, etc.)
- Success: Door unlocks temporarily
- Failure: Lockpick may break (consumed), alert may trigger for police
This creates dynamic interaction between locked doors and criminal RP â police lock things down, criminals try to break in.
Performance
| Script | Approach | Typical Resmon |
|---|---|---|
| ox_doorlock | Spatial indexing, streamed approach | 0.00-0.01ms |
| qb-doorlock | Distance loop per configured door | 0.01-0.05ms (depends on door count) |
| esx_doorlock | Similar to qb | 0.01-0.05ms |
For servers with 100+ configured doors, ox_doorlock's optimized approach is recommended. Config-based scripts that loop through every door entry can show higher resmon with large door counts.
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Door does not lock/unlock | Wrong door hash | Use in-game debug to verify the exact hash |
| Double door only one side works | Only one door configured | Add both door hashes to the config |
| Lock state does not persist after restart | Database not connected | Verify SQL import and database connection |
| Authorized player cannot open | Job name mismatch | Check exact job name in framework vs script config |
| Everyone can open locked doors | Script loaded before framework | Ensure door script loads after your framework |
â Browse All Scripts | â FiveM Script Installation Guide
Ready to Transform Your Server?
FiveM Job Creator eliminates every problem discussed in this article. 0.00ms resmon. No-code configuration. ESX & QBCore native.
Get Job Creator on Tebex â âŹ29.99