Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you kick players through a localscript?

4 answers

Turn on Filtering Enabled which is highly recommended to keep your servers secure and use remote events and functions to communicate between the server and client. This is how I would kick the player every time they click on their mouse.

--Inside server script

local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

event.OnServerEvent:connect(function(player)
	player:Kick("lol get kicked scrub")
end)


--Inside local script which is a child of the player's backpack

local player = script.Parent.Parent
local mouse = player:GetMouse()

mouse.Button1Down:connect(function()
	game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer(player)
end)

If you would like some more help on filtering enabled,remote events, and remote functions, here are some useful links: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent http://wiki.roblox.com/index.php?title=Security

There is still one way. You could make a RemoteEvent and put the Event in a secure folder so exploiter cannot abuse the event. Then you can do something like this:

local remoteevent = nil 

function kickPlr(plr)
	plr:Kick()
end

remoteevent.OnServerEvent:Connect(kickPlr)

and in the LocalScript:

local remoteevent = nil 

remoteevent:FireServer()

Instead of nil put the location of the event such as: game.ReplicatedStorage.KickEvent

So you can also do this:

game.Players.useryouhate:Kick("Reason")

this works 2

game.Players.nameoftheplayer:Destroy()

This discussion is preserved as it was. New answers, comments, and votes are closed.