How to remove the 'w' and 's' key movement (because I'd like to make a 2D game)

Hi, I’d like to remove the forward and backward movement on keyboard (meaning removing the use of ‘w’ & ‘s’ key to move). I’ve tried searching on YouTube but I couldn’t find anything about it.

3 Likes

You can access the player scripts and disable the w and s contextactionservice bind from there.

1 Like

A hacky way of doing this would be using ContextActionService and assigning an empty function to both of those keys. However: this only overrides the core scripts, and can easily be bypassed.

A better way of doing this would be by forking the scripts that are loaded in (usually in player.PlayerScripts).

Copy the player scripts from the player instance like I do:
image
Paste them into StarterPlayerScripts:
image
Control modules > Keyboard module script
image
Go into lines 88-94 and delete the body of the move forwards and backwards functions:

You now have a left-right control system for your game.

9 Likes

You can remove the bindings of the keys. Much simpler solution.

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:UnbindAction("moveForwardAction")
ContextActionService:UnbindAction("moveBackwardAction")

I don’t recommend forking systems unless you need to make major technical changes to them or if your use case is not natively supported by the engine.

4 Likes

Roblox has updated a bit so i will tell you how to do it in the updated version.

play the game then copy a script called “ControlScript” StarterPlayer>StarterPlayerScripts>ControlScript

then stop the game and paste under StarterPlayerScripts

next open the script to “KeyboardMovement” StarterPlayer>StarterPlayerScripts>ControlScript>MasterControl>KeyboardMovement

go to line 110-118, delete what ever key you want to remove

3 Likes