How do i disable some movement keys?

I am currently working on a 2d game, I’ve got the camera right, but the character can still move forward and backwards. To change this I think that I’ll need to disable s and w keys. If you know how to make this possible please inform me on how to do this.

I don’t know how to do this without entirely disabling the default character controls / making my own.
What might work instead though is using a PlaneConstraint.

Alternatively, I know a lot of games just put invisible walls on either side of the player.

Someone else had this question once before so I’ll link my response to this post.

But summary, you can use ContextActionService to disable it on PC.

For Mobile you may need to customize the walk system.

You can insert this in StarterPlayerScripts. 2D Game Player Module - Roblox (This only removes the w and s keys, doesn’t do anything else)

yeah the problem with that is that the player will still rotate the character

Thank you for the help, it worked

this isn’t a virus or anything right?

Nah I just took the original Roblox PlayerModule and just removed some lines, I tested it and it’s working fine

You can check the code yourself

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