How to kick player?

trying to kick player

using script in workspace

game.Players.PlayerAdded:Connect(function()
	wait(1)
	print(1)
	wait(2)
	print(2)
	wait(3)
	print(3)
	game.Players:WaitForChild("LocalPlayer"):Kick("Lol")
end)
5 Likes
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	task.wait(1)
	print(1)
	task.wait(2)
	print(2)
	task.wait(3)
	print(3)
	Player:Kick("Lol")
end)
13 Likes

LocalPlayer is for LocalScripts, and that’s not how you get the LocalPlayer.

1 Like

Normal script (ServerSide) in ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
player:Kick("lol")
end)

LocalScript (Client side & it works but it can be bypassed by exploiters) in game.StarterGui

game.Players.LocalPlayer:Kick("lol")

Aslo LocalPlayer can be only called by the client and not by the server

Useful links
developer.roblox.com - Roblox developer wiki
Player (roblox.com) - Player
Script (roblox.com) - Script (server side)
LocalScript (roblox.com) - LocalScript (client side)

7 Likes

Use this:

game.Players.PlayerAdded:Connect(function(player)
	wait(1)
	print(1)
	wait(2)
	print(2)
	wait(3)
	print(3)
	player:Kick("lol")
end)

ok ty thx guys lp;;;;;;;;;;;;;;;;;;;;;