Client-side kick script

I have made a client-side kick script, and confirmed that the script is registered correctly as I am able to log the entrance of the script. However, it doesn’t seem to enter the loop of users even that I know that a least one user is logged into the server.

Can anyone help me with this small script?

RegisterCommand('kick', function(source, args)
    local reason = args[2] or 'No reason specified'
    for _, k in ipairs(GetPlayers()) do
        local name = GetPlayerName(k)           
    	if name == args[1] then  	
    	    QBCore.Functions.Kick(k, reason, nil, nil)
    	end
    end
end, false)

Hi! use

GetActivePlayers()

instead of

GetPlayers()

It will return active players. But use server instead of client since If your game does not register other clients then it might not return All of the Active Players on the server.