[ script:gacha_peds] SCRIPT ERROR: @gacha_peds/server/Modules/Functions.lua:4: attempt to index a nil value (local 'xPlayer')

Hello good evening, question, how can I fix this error, it is from the gacha ped :d

is error

IsAuthorized = function(source)
    local xPlayer = ESX.GetPlayerFromId(source)
    for k,v in pairs(Config['groups']) do
        if v == xPlayer.getGroup() then
            return true
        end
    end
    return false
end

NewPedTable = function(identifier, model, label, target, xPlayer)
    local peds = {}
    table.insert(peds, {value = model, label = label})
    if not Config.UseGhmattimysql then
        MySQL.Async.execute("INSERT INTO gacha_peds (identifier, peds) VALUES (@identifier, @peds)", {
            ['@identifier']    = identifier,
            ['@peds'] = json.encode(peds)
        })
    else
        exports.ghmattimysql:execute("INSERT INTO gacha_peds (identifier, peds) VALUES (@identifier, @peds)", {
            ['@identifier'] = identifier,
            ['@peds'] = json.encode(peds)
        })
    end
    Peds[identifier] = CreatePedTable(identifier, peds)
    xPlayer.showNotification("Ped added successfully!")
    target.showNotification('You received a ped')
end

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