attempt to index a nil value (global 'QBCore')
QBCore's equivalent of the classic ESX error. How to get the core object correctly and the right load order.
1 min read
The problem
The console shows "attempt to index a nil value (global 'QBCore')" and your resource doesn't work or crashes on startup.
The cause
Your script uses QBCore before getting the core object, or qb-core starts after your resource. In QBCore you must request the core with the GetCoreObject export; assuming the global QBCore fails.
The solution
Get the core with the export and declare qb-core as a dependency:
lua
-- client.lua / server.lua
local QBCore = exports['qb-core']:GetCoreObject()
-- Player (server):
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.AddMoney('cash', 100)Step by step
- 1.In server.cfg, `ensure qb-core` must come BEFORE `ensure your_resource`.
- 2.Use `exports['qb-core']:GetCoreObject()` instead of the global QBCore.
- 3.Add `dependency 'qb-core'` (or the dependencies block) in your fxmanifest.lua.
- 4.Restart the whole server to apply the load order.
Related guides
Keep learning
Last updated: 2026-06-19. Crxative-M is not affiliated with Cfx.re or Rockstar Games.
