Frameworkcrash
attempt to index a nil value (global 'ESX')
Also seen as: attempt to index a nil value (global 'ESX') global ESX nil ESX is nil on join es_extended legacy broken
What causes it
The global ESX object is nil when your code uses it. On ESX Legacy / 1.9+, the old TriggerEvent('esx:getSharedObject', ...) pattern no longer works reliably (that event was deprecated/removed), so ESX never gets assigned. Resources still using the old pattern throw this on join.
How to fix it
Use the modern export to get ESX, and load es_extended before dependent resources.
- Replace the old pattern with:
ESX = exports['es_extended']:getSharedObject(). - In server.cfg, ensure
es_extendedstarts BEFORE every resource that uses ESX. - For many old third-party resources, apply the same one-line export fix at the top of their client/server files.
- If you must keep old resources working, a compatibility shim can re-add the esx:getSharedObject event — but updating the resource is cleaner.
Related errors
Related guides
Still stuck? We can help.
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.