Kick plr.name not working

normal script:

game.Players.PlayerAdded:Connect(function(plr)
	local rep = game:GetService("ReplicatedStorage")
	local rem = rep:WaitForChild("RemoteEvent")
	local rem2 = rep:WaitForChild("rem2")
	if plr.UserId == 3362150894 then 
		rem:FireClient(plr)
		wait(6.1)
	
		
	end
	rem2.OnServerEvent:Connect(function(plr)
		plr.Chatted:Connect(function(msg)
	local plrtokick = "kick "..plr.Name
			if msg == plrtokick then
			plrtokick:kick()
			
				end
				end)
				end)
end)

the only problem is the kicking part please help :frowning:

2 Likes

plr:Kick() instead of plrtokick:kick()

4 Likes

May god bless u :relieved:

it kicks me but not the player i want :V

You can simply kick the player on the server. And see the userid from the server

1 Like

how tho

edit: tried this and it still not wokring :confused:
script:

game.Players.PlayerAdded:Connect(function(plr)
	local rep = game:GetService("ReplicatedStorage")
	local rem = rep:WaitForChild("RemoteEvent")
	local rem2 = rep:WaitForChild("rem2")
	if plr.UserId == 3362150894 then 
		rem:FireClient(plr)
		wait(6.1)
	
		
	end
	rem2.OnServerEvent:Connect(function(plr)
		plr.Chatted:Connect(function(msg)
	local plrtokick = game.Players:FindFirstChild(plr.Name)
			if msg == "kick"..plrtokick then
				print("worka")
			plrtokick:kick()
			
				end
				end)
				end)
end)
1 Like

So a server script that does I’m on phone sooo

game.Players.PlayerAdded:Connect(function(plr)

If plr.UserId == __ the id then
plr:Kick(“ You we’re banned”)

end

end)

1 Like
local players = game:GetService("Players")

local whitelisted = {1, 2, 3} --Add whitelisted IDs here.

players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		local splitMessage = message:split(" ")
		if splitMessage[1]:lower():match("^:kick") then
			if table.find(whitelisted, player.UserId) then
				local chattedPlayers = {}
				for _, player in ipairs(players:GetPlayers()) do
					if player.Name:lower():match("^"..splitMessage[2]:lower()) then
						table.insert(chattedPlayers, player)
					end

					if #chattedPlayers == 1 then
						local chattedPlayer = chattedPlayers[1]
						chattedPlayer:Kick(splitMessage[3])
					end
				end
			end
		end
	end)
end)

I shouldn’t spoon feed but here you go. The command is :kick {PlayerNameHere} {OptionalMessageHere}. You can whitelist players that can use the command by inserting their ID into the array named “whitelisted” at the top of the code snippet.