Locking keys on the keyboard

Hello, there, developers.
I am sorry for my stupid question, but I want to know how to “lock” specific keys on the keyboard.

So, like the WASD keys functions are removed while you are in a dialogue with an NPC.

What do I want to achieve?:
Locking some keys from the keyboard of the player. So they don’t work anymore or for a period of time.

What I tried?:
I tried looking on YouTube but that wasn’t successful. Maybe because I don’t know the main words I want to describe the that I want to.

Bonus issue:
There is no bonus issue :slight_smile:

Thank you in advance!

2 Likes

You can use contextactionservice to unbind WASD keys. Or as an easier alternative, simply anchor humanoidrootpart.

3 Likes

Get the player module in PlayeraScript and use :Disable

3 Likes

This will lock all actions (chatting, moving, etc) I do not recommend this you should do what @commitblue said to use ContextActionService to unbind the keys you need then enable it back when you need.

2 Likes

That is incorrect. This won’t disable chatting, i also tested it.

local player = game.Players.LocalPlayer

local controls = require(player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()

controls:Disable()

This will only disable movement

2 Likes