THE ORB
Starting the studio

attempt to call a nil value

A script tried to use a function that does not exist — usually because it was written for a different version of your framework.

groupsThat feature stops workingcodeNeeds a developer

Do this first

Check the script was made for your framework and your version of it.

bug_reportPaste your whole console instead

What it means

The script tried to invoke something that is not a function. The parenthesised name says what: (global 'ESX'), (field 'GetPlayerData'), (method 'getJob').

method 'x' is worth reading carefully: it means the call used a colon (obj:x()) and the table has no x. That is nearly always a framework version difference, where the method was renamed or moved.

What causes it

Ordered by how often it is the answer.

  1. 1

    A native that does not exist on this side

    Client natives called on the server, or the reverse. Most drawing, input and camera natives are client only, so on the server that global is simply nil and calling it is calling nil.

  2. 2

    A framework method renamed between versions

    xPlayer.getJob() vs xPlayer.job, QBCore.Functions.GetPlayerData vs PlayerData, ESX Legacy vs ESX 1.1. Scripts written for one version call methods the other does not have.

  3. 3

    An export that resolved to nil

    exports['res']:method() where the resource is stopped, misnamed, or exports no such name. FiveM returns nil rather than throwing, so the failure lands here.

  4. 4

    The function is defined further down the file

    Lua assigns local function f when that line runs, not at parse time. Calling f() above its definition calls nil.

  5. 5

    A typo

    TriggerServerEvnet, or GetPlayerPedId when the real native is PlayerPedId.

How to tell which one is yours

print(type(theThing))

above the call. nil for a native means you are on the wrong side — check the native reference, which lists client/server for every entry. table means you are calling a table, which usually means . was used where : was needed.

Where to look

The named file and line. If the name is a global native, search the native reference before assuming your own code is wrong.

How to fix it

-- exports: check the resource is up before trusting it
if GetResourceState('ox_inventory') ~= 'started' then return end
local count = exports.ox_inventory:Search(src, 'count', 'water')

-- framework methods: read that version's API, do not guess
local job = xPlayer.job          -- ESX Legacy
-- local job = xPlayer.getJob()  -- older ESX

Still stuck on your own code?

This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.

bug_reportOpen Server Fixer

Errors that travel with this one