What's new

Advertisement The dreaded attempt to index a nil value (global 'ESX') Error on FiveM Server

TwistedMe2u

Member
Joined
Jan 7, 2023
Messages
2
Reaction score
7
Points
96
Location
US
If you have your own FiveM server and you are running ESX platform; you have come across the error

attempt to index a nil value (global 'ESX')​

this is a ESX version issue for version greater than 1.9 and scripts that are attempting to retrieve ESX shared object in a way thats been depreciated. Please remove code in the files where the ESX object is being set to "nil" and the function usually right after it that is retrieving the shared object. Please see example bad code below

Code:
ESX = nil

 TriggerEvent(
     "esx:getSharedObject",
     function(obj)
         ESX = obj
     end
 )

Replace that code above with this code:

Code:
ESX = exports['es_extended']:getSharedObject()

Please like this if it helped you!!! THANKS!!! :)
 

Kennyata

Member
Joined
Dec 4, 2022
Messages
12
Reaction score
0
Points
96
Location
Spian
If you have your own FiveM server and you are running ESX platform; you have come across the error

attempt to index a nil value (global 'ESX')​

this is a ESX version issue for version greater than 1.9 and scripts that are attempting to retrieve ESX shared object in a way thats been depreciated. Please remove code in the files where the ESX object is being set to "nil" and the function usually right after it that is retrieving the shared object. Please see example bad code below

Code:
ESX = nil

 TriggerEvent(
     "esx:getSharedObject",
     function(obj)
         ESX = obj
     end
 )

Replace that code above with this code:

Code:
ESX = exports['es_extended']:getSharedObject()

Please like this if it helped you!!! THANKS!!! :)
nice work and ty for work!!!
 
Top