How to disable Keyboard or any Movement Keys?

Hi I’m currently making a Grenade catch System by forcing the player to move to the direction of the Grenade but there’s a problem where if you move it will just break the Scripts.

This is when I don’t press any Movement Key:

This is when I pressed a Movement Key:

I have tried using UserInputService to disable the Keyboard and also tried disabling the Keys using the Mouse Key but it won’t work.

1 Like

Use CAS (ContextActionService); when you bind this to an input, like W, it will completely rewrite its function (to move you forward). Here’s an example:

local cas = game:GetService("ContextActionService")

cas:BindAction("action-name", function(_, state) print("blank") end, false, Enum.KeyCode.W)

This was written on the devforum, so some of it may not be spelled correctly.

also for getting the original function back… I have no clue :man_shrugging: :man_shrugging:

2 Likes

Hmmm alright I’ll try it after this.

Unfreezing is simple. Just use the UnbindAction to the corresponding action name in the first parameter and it will go away. There was also an example of disabling all character input I remember from several years ago.

I’m also trying to find one that works on Server Script and not just Local Script.

1 Like

Not possible. Inputs from the mouse, keyboard, etc. are all handled on the client; it is impossible to access them from the server. The best you could do is handle them on the client and use RemoteEvents to tell the server you’ve done the input.

(I’ll just cease to exist for opening a solved topic :pray::pray::pray:)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.