FiveM Docs
Getting Started

Fix ESX Is Nil / getSharedObject Errors

Fix ESX is nil, attempt to index a nil value and no such export getSharedObject in ESX Legacy, with verified imports.lua examples and resource load-order checks.

If your console reports ESX is nil, attempt to index a nil value (global 'ESX') or No such export getSharedObject, inspect the resource import and whether es_extended is running.

fxmanifest.lua
fx_version 'cerulean'
game 'gta5'

shared_scripts {
    '@es_extended/imports.lua',
    'config.lua',
}

client_script 'client.lua'
server_script 'server.lua'
dependency 'es_extended'

The import makes ESX available on both sides, but server-only APIs must still run on the server. The import must be loaded before your resource's own files.

Alternatively, retrieve the export after the framework loads:

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

Has esx:getSharedObject really been removed?

No. The maintained ESX Legacy 1.16.4 source still registers this event for backward compatibility:

local ESX
TriggerEvent('esx:getSharedObject', function(object)
    ESX = object
end)

It is a legacy pattern. Prefer @es_extended/imports.lua or exports['es_extended']:getSharedObject() for new code, but do not claim that the old event no longer exists.

Troubleshoot the exact message

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

  1. Check the shared_scripts entry and its order.
  2. Add dependency 'es_extended' in fxmanifest.lua.
  3. Confirm that es_extended started without errors.
  4. Search for a conflicting or uninitialized local ESX variable.

No such export getSharedObject in resource es_extended

Check the es_extended folder name, whether its fxmanifest.lua is at the correct level and whether the core actually started. The export exists in the maintained source; startup failures can prevent it becoming available.

Couldn't load resource es_extended

Look for the first server error rather than changing the export call. Dependencies such as esx_lib and oxmysql may be missing. See ESX troubleshooting.

ESX.GetPlayerFromId is nil

ESX.GetPlayerFromId is a server-side function. Use the server API on the server and the client API on the client.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.

Last updated on

On this page