I can't seem to disable forward and backward movement

So I’m trying to make a 2D game for fun, and I’ve had a hard time figuring out how to disable movement forward and backward, or w, s, up, and down keys. I’ve read multiple conversations about this already, such as This one as well as This one

For the first page, (first post) with the script shown using the ``` method, (which looks different than normal text), I copied that and it says Argument 2 missing or nil. With the other script that was provided at the end of that post, it gives no errors, but doesn’t work.

For the second page, it seems to use a different function name, and doesn’t work either, giving Argument 2 missing or nil once again.

This is all done in the Solo test in Studio btw. Hope someone can help.

The best solution I can think of off the top of my head would be to create a new local script (Preferably under starterPlayerScripts) with the following code

local ContextActionService = game:GetService("ContextActionService")

require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")) --Makes sure that the keys get bound before attempting to unbind

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