Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to temporarily disable most movements?

Asked by
eyad27 8
2 years ago

I am trying to figure out a way to temporarily disable the left and right movements without disabling the keys entirely. I've tried using ContextActionService sink, but it disables the key entirely. That's not what I want. I want to temporarily disable the left and right movement keys so I can use the A and D keys for something else. Before you tell me to look at other posts, I have looked around many posts, but none of them seem to solve the problem entirely.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

There's a good answer on the Dev Forum I've found posted by Kampfkarren Credit goes all to them.

This is easy to do because movement is done through core scripts.

-- TODO: remove up and down arrows, these seem unnecessary
    ContextActionService:BindActionToInputTypes("forwardMovement", moveForwardFunc, false, Enum.PlayerActions.CharacterForward)
    ContextActionService:BindActionToInputTypes("backwardMovement", moveBackwardFunc, false, Enum.PlayerActions.CharacterBackward)
    ContextActionService:BindActionToInputTypes("leftMovement", moveLeftFunc, false, Enum.PlayerActions.CharacterLeft)
    ContextActionService:BindActionToInputTypes("rightMovement", moveRightFunc, false, Enum.PlayerActions.CharacterRight)
    ContextActionService:BindActionToInputTypes("jumpAction", jumpFunc, false, Enum.PlayerActions.CharacterJump)

This code was found on the ROBLOX Core Script on Github

Simply run:

ContextActionService:UnbindAction("leftMovement")
ContextActionService:UnbindAction("rightMovement")

Hopefully this answers your question!

Ad

Answer this question