How can I make a script that kicks a player on key press?

Say if I wanted the player to be kicked when pressing Esc. instead of showing the menu, or a button that the game doesn’t use but is associated with exploits or something along those lines, how would I achieve it?

(I don’t know anything about scripting)
Thanks for the help in advance!


Ah i’m pretty sure the scripting support section was created to help other developers with roblox lua coding, if i’m not wrong?

Im not currently on my pc so i wouldn’t be able to help u but heres a yt vid explaining user input service

And in the function for the key press do
game.Players.LocalPlayer:Kick(“haha u got kicked”)

I dont see why ur being so toxic they are simply asking for help.

1 Like

I would use this to help you do what you’re trying to do

In all honesty its just better to not answer at all instead of saying no one will give you the code

I really don’t know why you want to kick players but here is a little script I made.

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.Escape then
		game.Players.LocalPlayer:Kick("Your kick reason here")
1 Like

Toxic where am I being toxic?? I deleted my messages before this goes into somewhere we don’t want it to go, a lot off programmers isn’t just give free code out then what’s the point off hiring if people could just ask programmers to do it in here. That’s all i was saying.

I be the big man and walk away.

Where would I put this script?

You should put a local script into ScreenGui or StarterPlayerScripts.

1 Like
UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input, Istyping)
if Istyping then

if input.KeyCode == Enum.KeyCode.Escape then


They said they have no scripting knowledge so why would someone hire them for scripting, also the point of this channel thing is to help people with scripts, im sure u and me have both asked something for our errors, or looked at a past post to discover why we had that error.

Right, My bad, I just re-read the rules and guilds my bad. Sorry to the user!

Thats client sided, not sure if you can kick from the client…

Thats fine we all make mistakes!

You can. I just tested my script and is works fine.

I’m going to put together a file which you can tweak or import into your game. brb when Im done.
Edit: or not

oh wow roblox is so much more vulnerable than I thought
Edit: On second thought I’m wondering if you can kick other players. it may only work for the client…

Yep, only for the client. :smiley:

1 Like

Exploit clients finding a way around filtering enabled: