Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way to temporarily disable most movements?

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

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.