Attempt to index a nil value (upvalue 'ESX')

hey When I do the command I get the error:

SCRIPT ERROR: @10system/server.lua:9: attempt to index a nil value (upvalue 'ESX')

The error in this line:

local xPlayer = ESX.GetPlayerFromId(src)

And this is the full code:

RegisterCommand("plist", function(source, args)
    local src = source
    local xPlayer = ESX.GetPlayerFromId(src)

        if xPlayer and (xPlayer.job.name == 'police' or xPlayer.job.name == 'offpolice') then
            local type = "toggle"

            if args[1] == "0" then
                type = "drag"
            end

            TriggerClientEvent("nv:officers:open", src, type)
        end
end)

Is there a way to fix this?
Thanks in advance!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.