How can I disable The S movement of roblox?

Hello, I would like to know how can I disable the S movement or the “Moving Backward” in Roblox.

I only want to disable it for a certain time and then renabling it back after a certain condition.

robloxapp-20240823-1803140.wmv (387.8 KB)

Any help is appreciated!

(PS: The video doesn’t seem to play so anyways, the video is about me showing the Backward movement of Roblox)

3 Likes

Saw this script that disables the W button. Basically you replace the function that runs when you click it. I haven’t tested it so I’m not sure if it would work, but you could try!

local cas = game:GetService("ContextActionService")

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

Thank you so much for your help!

However, sadly I have tried that, it won’t let me rebind it no matter how I try.

You can retrieve every binded action using ContextActionService:GetAllBoundActionInfo(), and Roblox uses the action moveBackwardAction for moving backwards, so we can use the method ContextActionService:UnbindAction() to disable it.

local contextActionService = game:GetService("ContextActionService")

contextActionService:UnbindAction("moveBackwardAction")
2 Likes

You could or detect when S is pressed and make the WalkSpeed 0, or you could modify the controls by playing the game going to StarterPlayer > StarterPlayerScripts > PlayerModule > ControlModule > Keyboard, findthe function that gets if you’re backwards and use a RemoteEvent to enable/disable it.

1 Like

You can reload the PlayerModule by manually requiring it require(game.Players.LocalPlayer.PlayerScripts.PlayerModule), this will rebind all movement keys but it will also reset the camera

This is also correct but extremely inefficient.

I don’t see why it’s inefficieent, but it’s the first thing that came to mind.

Anything involving Events has a chance to be unreliable (inefficient). If a player were to, in quick succession, press the S key repeatedly, the RemoteEvent could fail to fire.

1 Like

Forgot that. Wasn’t in Roblox Studio at the time. Maybe not using remoteevents could be fine, or somehting similaeçr

1 Like

Thank you for all of your replies, I’ll be sure to try them out and see which one works!

1 Like

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