dropPlayer argument at index 0 was null

Hi,
I’m new to fivem scripting and I’m trying to figure out the dropPlayer native to kick a player from server.
I’ve passed source as argument but I’m getting the following error.

InvokeNative: execution failed: Argument at index 0 was null.
SCRIPT ERROR: Execution of native 00000000ba0613e1 in script host failed.
> handler (@loginsignup/login-s.lua:18)

Line 18 of the login-s.lua is the dropPlayer native calling

login-c.lua

local spawnPos = vector3(686.245, 577.950, 130.461)
local display = true

AddEventHandler('onClientGameTypeStart', function()
    SetDisplay(not display)
    TriggerServerEvent("connectingsteam")
    exports.spawnmanager:setAutoSpawnCallback(function()
        exports.spawnmanager:spawnPlayer({
            x = spawnPos.x,
            y = spawnPos.y,
            z = spawnPos.z,
            model = 'a_m_m_skater_01'
        }, function()
            TriggerEvent('chat:addMessage', {
                args = { 'Welcome to the party!~' }
            })
        end)
    end)

    exports.spawnmanager:setAutoSpawn(true)
    exports.spawnmanager:forceRespawn()
end)

login-s.lua

RegisterServerEvent("connectingsteam")
AddEventHandler("connectingsteam", function(source)

        DropPlayer(source, 'connect to steam')    --THIS IS LINE 18
   


end)

ok in the TriggerServerEvent I added source as second argument and the error disappeared , but I’m still not getting kicked when connecting

TriggerServerEvent("connectingsteam", source)

Don’t add source to your callback parameters, it’s already a global variable

1 Like

Following page might help

In Lua/JS, the source variable (global) will contain the player ID that triggered the event. You should most likely save it in a local variable if you’re going to use it after the event returns.

Whew thank you!!!
That fixed the problem.
Is there any fivem doc that lists all the global variables?