Fix: attempt to index a nil value (global 'QBCore')
Fix attempt to index a nil value (global 'QBCore') on QBCore and Qbox: replace the removed import.lua with GetCoreObject, fix start order, check the bridge.

- Applies to
- FiveM Legacy and FiveM for GTAV Enhanced; QBCore (qb-core 1.3.0, repository as of 2026-08-24) and Qbox through its QB bridge (qbx_core v1.24.1, 2026-10-30)
- Last verified
On this page
- Direct Answer
- What “attempt to index a nil value (global ‘QBCore’)” means
- Why QBCore is nil: the import methods qb-core removed
- How to fix “attempt to index a nil value (global ‘QBCore’)”
- attempt to index a nil value (upvalue ‘QBCore’)
- “No such export GetCoreObject in resource qb-core”: start order, ensure and dependency
- QBCore scripts on Qbox: “No such export GetCoreObject in resource qbx_core”
- When the error points inside qb-core itself
- Troubleshooting
- Next Steps
Direct Answer
attempt to index a nil value (global 'QBCore') means a script read the QBCore variable before anything stored the core object in it. Either that file never fetches the core object, or the script still relies on @qb-core/import.lua or the QBCore:GetObject event, which qb-core removed in 2021 and 2022. To fix it, delete the @qb-core/import.lua line from the script’s fxmanifest.lua, add local QBCore = exports['qb-core']:GetCoreObject() as the first line of every client and server file that uses QBCore, and start the script after qb-core in server.cfg. On Qbox, keep the bridge enabled and fetch the core object from exports['qb-core'], not from exports.qbx_core.
What “attempt to index a nil value (global ‘QBCore’)” means
FiveM runs Lua resources on CfxLua, a modified version of Lua 5.4. When a script indexes a value that is nil, for example QBCore.Functions while QBCore holds nothing, the runtime builds its error from the pattern attempt to %s a %s value%s. Here the operation is “index” and the type is “nil”. When Lua can identify the variable, it appends the variable’s kind and name in brackets.
QBCore is meant to hold the core object. QBCore’s documentation calls it “the backbone of the qb-core framework”: a table with parts such as Functions, Players, Shared, Config and Commands. A script does not own that table. It has to fetch it from the qb-core resource when it starts.
The line named in the error is only where the script first used QBCore. The fault is an earlier line that should have fetched the core object and never did.
Global, upvalue, local or field: what the bracket tells you
The word before the name narrows the cause. Lua’s manual treats a variable name as global “unless explicitly declared as a local”, says a variable’s value is nil before its first assignment, and calls a local variable used by an inner function an upvalue.
| Console text | What Lua found | Usual cause |
|---|---|---|
(global 'QBCore') | No local QBCore is in scope at that line, and no global with that name holds a value | The removed import.lua, the old QBCore:GetObject event written with a global QBCore = nil, or a GetCoreObject line that sits in another file |
(upvalue 'QBCore') | The file declares local QBCore, and a function used it while it was still nil | The old QBCore:GetObject event written with local QBCore = nil, or a framework option that skips QBCore |
(local 'QBCore') | The same, when the failing line is in the function, or at the top level of the file, that declared the variable | Same as upvalue |
(field 'Functions') or (field 'Shared') | QBCore is a table, but that key is empty | A filtered GetCoreObject call |
No such export GetCoreObject in resource qb-core | No running resource answered the export | Start order, a renamed core folder, or the Qbox bridge switched off |
No such export GetCoreObject in resource qbx_core | The script asked Qbox itself for a core object | Qbox has no core object; its bridge answers under the name qb-core |
Where to read the full error
Server-side errors show in the server console, which txAdmin presents as the Live Console. Client-side errors show in the client console, which you open by pressing F8. FiveM names every script chunk @resource/file, so the message tells you which file to open:
SCRIPT ERROR: @qb-overlord-laundering/server/main.lua:14: attempt to index a nil value (global 'QBCore')
That line was posted on the Cfx.re forum in December 2021. It points at line 14 of server/main.lua in the resource qb-overlord-laundering. Runtime errors carry the SCRIPT ERROR: prefix. An error raised while a file first loads starts differently, as in Error loading script server.lua in resource hh_vehextras, and ends with the same Lua message.
Why QBCore is nil: the import methods qb-core removed
qb-core has offered three ways to hand its core object to other resources: the QBCore:GetObject event, the import.lua file and the GetCoreObject export. Only the export still exists.
| Date | Change in the qb-core repository | Effect on other scripts |
|---|---|---|
| July 1, 2021 | import.lua added. It exported GetSharedObject and assigned a global QBCore | One manifest line gave every file of a script the QBCore global |
| September 24, 2021 | “Major Update”: the GetCoreObject export arrives “as an alternative to import.lua”, and the QBCore:GetObject event handlers are deleted | A script that waits for that event never receives the object |
| November 10, 2021 | import.lua deleted (“Remove import”) | GetSharedObject is gone |
| November 30, 2021 | import.lua added again, now calling GetCoreObject | The file named by the manifest line exists again, until January 10, 2022 |
| January 10, 2022 | import.lua moved to shared/import.lua and deleted the same day (“remove import”) | The manifest line fails from here on |
| May 19, 2026 | Core refactor: client/main.lua and server/main.lua deleted, GetCoreObject exported from shared/main.lua | The export call itself is unchanged |
On November 20, 2026, the repository’s last commit is dated August 24, 2026, and its manifest declares version 1.3.0. At that commit qb-core has no import.lua, no GetSharedObject export and no QBCore:GetObject handler.
A script written for import.lua carries this in its manifest. The block below is what the official qb-shops resource contained until its “remove old import” commit of November 8, 2021:
shared_scripts {
'@qb-core/import.lua',
'config.lua'
}
A script written for the event method starts its Lua files like this, quoted from a forum post that explains how to update such a script:
QBCore = nil
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
Both leave QBCore empty on a current qb-core. In the first case the file is gone: FiveM prints Failed to load script @qb-core/import.lua. and goes on loading the script’s other files, which then find no QBCore. In the second case nothing answers the event.
Do not wait for a qb-core update to bring the old imports back. QBCore’s documentation says “QBCore has withdrawn from other platforms” and that the existing pages “cover the previous QBCore implementation”. The first post of its Cfx.re forum thread now reads “QBCore has left the platform”, with the code staying on GitHub. The fix has to happen in the script. The QBCore vs Qbox vs ESX comparison explains what that status means for a whole server.
How to fix “attempt to index a nil value (global ‘QBCore’)”
These steps apply to QBCore servers and to Qbox servers that run QBCore scripts through the bridge. They are the same on FiveM Legacy and FiveM for GTAV Enhanced: Cfx.re’s list of what changed for Enhanced does not mention exports, dependency or shared_script.
-
Find the file and the line. Read the console message and note the resource, the file, the line, and whether it came from the server console or from F8.
-
Open the script’s manifest. It is
fxmanifest.luain the resource folder, or__resource.luain a very old resource. Delete any'@qb-core/import.lua'entry. -
Add the export line at the top of the file named in the error. QBCore’s Core Object page gives this pattern for “the top of your script” and says to cache the object in a local variable:
local QBCore = exports['qb-core']:GetCoreObject() -
Repeat for every file that uses
QBCore. FiveM loads each script file as its own Lua chunk, and a chunk’s local variables belong to that chunk. A line added toconfig.luadoes nothing forserver/main.lua. The removedimport.luacovered a whole script only because it assigned a global, without the wordlocal. Search the resource forQBCore.and check the top of every file that turns up, shared files included. -
Delete the old event code. Remove the
QBCore = nilline, theTriggerEvent('QBCore:GetObject', ...)call and any loop that waits for it. Step 3 replaces all of it. AQBCore = nilline left below the newlocalline would empty the variable again. -
Start the script after the core. In
server.cfg, the script’sensureline, or theensureline of its category folder, must come afterensure qb-core, or afterensure qbx_coreon a Qbox server. The section on start order below shows how to enforce this from the manifest. -
Reload and test. In the server console run
refresh, thenensurefollowed by the resource name.refreshrescans the resources folder and loads the manifests again.ensurerestarts a running resource, or starts it if it was stopped.
The Cfx.re forum thread that has this error as its title was solved this way. The poster’s code fetched the object in what a reply called “the ESX way”, and replacing that line with the export call ended the error. A later reply in the same thread adds that the line “should be at the very top of the file line 1”.
When you choose resources, including FiveCrate’s FiveM scripts, check which framework each one expects and how it fetches the core object before you install it. The general routine is in How to install FiveM scripts.
attempt to index a nil value (upvalue ‘QBCore’)
The upvalue variant means the file does declare local QBCore near its top, but the variable was still empty when a function used it. Two situations produce it.
-
The old event with a local variable. The forum post quoted earlier for the event method also gives its client-side version:
local QBCore = nil Citizen.CreateThread(function() while QBCore == nil do TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) Citizen.Wait(200) end end)The loop asks for an event that qb-core stopped answering on September 24, 2021, so
QBCorestaysnilfor good. Replace the whole block with the export line from step 3. -
A framework option that skips QBCore. According to Qbox’s documentation, many scripts have settings that choose what they work with. A script that declares
local QBCoreand assigns it only in its QBCore mode leaves itnilin every other mode, because a Lua variable isnilbefore its first assignment. Open the script’s config and check the framework option. On a QBCore server it has to select QBCore. On a Qbox server, Qbox’s docs say to chooseqbxorqboxif it is offered, otherwiseqborqbcore.
“No such export GetCoreObject in resource qb-core”: start order, ensure and dependency
Once a script uses the export, a missing core no longer shows as a nil value. FiveM turns exports['qb-core']:GetCoreObject() into an event named after the resource and the export. When no handler replies, it raises No such export GetCoreObject in resource qb-core. qb-core registers that handler from shared/main.lua, under the name of the folder it runs from.
Four causes follow from that.
-
The script started before qb-core. The QBCore txAdmin recipe starts the core first and its categories afterwards:
ensure qb-core ensure [qb] ensure [standalone]A script whose
ensureline sits aboveensure qb-coreasks for the export too early. Move the line down, or add this to the script’s manifest:dependency 'qb-core'The manifest reference says
dependency“Requires the specified resource to load before the current resource”. In FXServer’s source, a dependency that is neither starting nor started gets started first. -
The core folder was renamed. The export is looked up by resource name. If the core’s folder is not called
qb-core,exports['qb-core']has nothing to reach. -
qb-core itself did not start. Its manifest declares
dependency 'oxmysql'. When a dependency is missing, the console line has the formCould not find dependency oxmysql for resource qb-core., and every QBCore script fails after it. Work through Couldn’t start resource for the core first. -
The script calls an export the core does not have. QBCore’s docs date two features to qb-core 1.3.0: the filter argument of
GetCoreObject, and one export per core function, as inexports['qb-core']:GetPlayer(source). A script that calls a per-function export on a core without it stops with aNo such exporterror that names that function instead ofGetCoreObject. The docs tell you to check the version in qb-core’sfxmanifest.lua.
The same message with other resource names is covered in No such export errors.
QBCore scripts on Qbox: “No such export GetCoreObject in resource qbx_core”
Qbox has no core object. Its core resource, qbx_core, ships a bridge instead. The manifest of qbx_core declares provide 'qb-core', and the bridge answers exports['qb-core']:GetCoreObject() with the familiar QBCore object, whose functions call qbx_core and ox_inventory underneath. Qbox’s documentation says the bridge covers QBCore 1.3.0’s functions, exports and events. On November 20, 2026, the newest qbx_core release is v1.24.1, published on October 30, 2026.
| Symptom on a Qbox server | Cause | Fix |
|---|---|---|
No such export GetCoreObject in resource qbx_core | The script calls the export on qbx_core | Call exports['qb-core']:GetCoreObject(). The Qbox FAQ gives this answer under the same error text |
No such export GetCoreObject in resource qb-core | The bridge is switched off, or the script started before qbx_core. The bridge’s client and server files stop at their first line when the convar is false | Keep setr qbx:enableBridge "true" in server.cfg. The Qbox recipe sets it, and true is the default. Then check the start order |
| Double menus, commands and errors | A real qb-core folder runs next to qbx_core | Delete the qb-core folder, as Qbox’s docs instruct |
(global 'QBCore') from an old script | The script uses import.lua, GetSharedObject or QBCore:GetObject, none of which the bridge provides | Apply the fix steps above. The export line is identical on Qbox |
Start order works the same way. The Qbox recipe starts ox_lib and qbx_core before its resource categories. Qbox’s Your own scripts page tells you to keep your own scripts in resources/[custom] and to add ensure [custom] “at the very bottom of server.cfg, below all other ensure lines, so your scripts start after Qbox”. Because qbx_core provides qb-core, a script that declares dependency 'qb-core' starts normally.
When the error points inside qb-core itself
If the path in the error begins with @qb-core/, the core’s own files are out of step. In the current repository QBCore = {} is the first line of config.lua, and config.lua is the first entry of the core’s shared_scripts. Every later core file assumes the table exists. Two things break that assumption.
config.luadid not load. A file with a syntax error is reported with a line beginningError parsing script, and FiveM then loads the remaining files anyway. Look higher in the console for the first error aboutconfig.luaand fix that one. The nil errors below it are consequences.- Files from two qb-core versions are mixed. Until the refactor of May 19, 2026,
QBCore = {}lived inclient/main.luaandserver/main.lua, and data files such asshared/items.luabegan withQBShared = QBShared or {}. Since that commit the data files assign straight to the core table, as inQBCore.Shared.Items = {. FiveM loads a resource’s shared scripts before its client or server scripts. A newershared/items.luacopied into an older core therefore runs beforeQBCoreexists. Use one complete version of theqb-corefolder and redo your edits by hand.
Troubleshooting
QBCore is nil in one file but works in another
The local QBCore line covers one file only. The forum thread behind the console example above shows it: the poster added the export line to config.lua and still got the error from server/main.lua:14. A second user with the same error reported that it worked once the line was also added to the top of server/main.lua.
The file has the GetCoreObject line and still reports (global ‘QBCore’)
- The line is too low. The scope of a local variable begins at the first statement after its declaration. A function written above the line does not see the local and reads a global instead. Move the line to line 1.
- The name is spelled differently. Lua is case-sensitive. The error prints the name exactly as the failing line spells it, so compare it letter by letter with the name in your
localline. - The error is from the other side. A
client_scriptruns on the client and aserver_scripton the server. A line added to a server file does not help an error you see in F8.
“Failed to load script @qb-core/import.lua.”
The manifest still lists the removed file. A December 2021 forum post shows the line this produces, followed by a second error from the script’s own config.lua, whose line 1 still called the GetSharedObject export:
[ c-scripting-core] Failed to load script @qb-core/import.lua.
[script:qb-overlord-l] Error loading script config.lua in resource qb-overlord-laundering: citizen:/scripting/lua/scheduler.lua:881: No such export GetSharedObject in resource qb-core
Delete the '@qb-core/import.lua' entry from the manifest, then follow the fix steps. For the manifest file itself, see fxmanifest.lua explained.
“No such export GetSharedObject in resource qb-core”
GetSharedObject was the export of the 2021 import.lua and went away with it on November 10, 2021. Replace the call with exports['qb-core']:GetCoreObject().
“attempt to index a nil value (field ‘Functions’)” or (field ‘Shared’)
The script asked for part of the core object. With a filter list, qb-core and the Qbox bridge both return only the keys you name, so GetCoreObject({ 'Functions' }) has no Shared. Add the missing key to the list, or call GetCoreObject() with no argument for the full object.
A field one level deeper, such as (field 'Items') or (field 'Jobs'), points at qb-core’s own data files. A reply in the forum thread titled with this error says that if the message names jobs, jobs.lua has a syntax error, and if it names items, items.lua has one. When qb-core starts, look for an Error parsing script line that names shared/items.lua or shared/jobs.lua.
The error started after updating an official qb- resource
On May 19, 2026, the official qb-shops resource received a commit titled “Don’t import whole core”. Its client files now request { 'Functions' } only, and its server/main.lua lost the GetCoreObject line. Custom code pasted into such a file that uses QBCore.Shared, or uses QBCore at all on the server side, fails with a field or global error. Add the keys you need, or add the export line back.
The same commit moved the resource’s server code to exports['qb-core']:GetPlayer(source), one of the per-function exports that QBCore’s docs date to qb-core 1.3.0. An updated resource therefore also needs a core that has those exports.
The script is escrowed and cannot be edited
Qbox’s docs describe an escrowed script as one whose folder has a .fxap file and whose Lua files look like gibberish, and add: “You can only change its config.” Set its framework option and fix the start order. If it still needs a removed import, only its author can update it. For FiveM for GTAV Enhanced, Cfx.re’s list of changes marks Asset Escrow as “Not implemented yet”.
“attempt to call a nil value (field ’…’)” on Qbox
This is a missing function, not a missing core object. Qbox’s docs say that when a QBCore script fails this way on a QBCore function, you should update qbx_core first.
Errors appear after restarting qb-core on a live server
The comment in qb-core’s removed import.lua explains why: “Whenever qb-core is restarted, the shared object table containing function refs becomes invalid”. Scripts that cached the core object keep the old table. FXServer also stops every resource that declares the core as a dependency when the core stops, and a comment in its source says such a resource ends up “stopping but not being started again”. Restart the scripts that use the core once it is running again, or restart the server.
Next Steps
- Move the whole server off QBCore with How to migrate a QBCore server to Qbox.
- For the same kind of error in ESX scripts, see ESX getSharedObject errors.
- If
qb-coredoes not start becauseoxmysqlcannot reach the database, work through oxmysql ECONNREFUSED.
FiveM scripts from FiveCrate
Listed in the FiveCrate catalogue now.
Official documentation and repository references
Related guides
Fix FiveM 'Couldn't Start Resource' and Dependency Errors
Couldn't start resource in FiveM means a start check failed. Read the line above it, then fix the dependency, manifest, server build or folder name.
Fix 'No Such Export in Resource' Errors in FiveM
Fix 'No such export in resource' in FiveM: find why the export is missing, then check the resource name, start order, client or server side and version.
Fix 'getSharedObject Event No Longer Exists' and ESX is nil
Fix the ESX getSharedObject event no longer exists error and ESX is nil: which es_extended versions cause it, and how to update ESX or convert the script.
How to Migrate QBCore to Qbox Safely (With a Rollback Plan)
Migrate QBCore to Qbox on a test copy: what carries over, the database and qb-inventory conversion commands, go-live day and a rollback plan from Qbox's docs.
QBCore vs ESX vs Qbox: Which FiveM Framework in 2026?
QBCore vs ESX vs Qbox in 2026, from official sources: what QBCore leaving FiveM means, how Qbox and ESX Legacy differ, and which framework fits your scripts.


