Error with kick event

Having trouble with my remote. It says error line 11 attempt to call an instance value.

I don’t see what the problem is. Basically if you’re whitelisted it’s supposed to let you kick the player when you click a button the gui. Heres the remote script in serverscriptservice:

local KickEvent = game:GetService("ReplicatedStorage").Events.Fixcam

local admins = {
	["danthespam"] = true,
	["Xerxius"] = true, 
}

KickEvent.OnServerEvent:Connect(function(player, KickPlayer)
	local PlayerKick = game.Players:FindFirstChild(KickPlayer)
	if admins[player.Name] and PlayerKick then
		PlayerKick("An administrator has removed you from the game")
	end
end)

Edit: If you are looking to use this code heres the correct code:

 local KickEvent = game:GetService("ReplicatedStorage").Events.Fixcam

    local admins = {
    	["danthespam"] = true,
    	["Xerxius"] = true, 
    }

    KickEvent.OnServerEvent:Connect(function(player, KickPlayer)
    	local PlayerKick = game.Players:FindFirstChild(KickPlayer)
    	if admins[player.Name] and PlayerKick then
    		PlayerKick:Kick("An administrator has removed you from the game")
    	end
    end)
1 Like

the reason is because you never used the :Kick part of the function like this:

player:Kick("Reason")
4 Likes