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

How to unbind movement keys and rebind them?

I guess the title is pretty self-explanatory.

2 answers

✓ Accepted answer

PlayerModule --> ControlModule --> Keyboard, line 120-129:

	ContextActionService:BindActionAtPriority("moveForwardAction", handleMoveForward, false,
		self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterForward)
	ContextActionService:BindActionAtPriority("moveBackwardAction", handleMoveBackward, false,
		self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterBackward)
	ContextActionService:BindActionAtPriority("moveLeftAction", handleMoveLeft, false,
		self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterLeft)
	ContextActionService:BindActionAtPriority("moveRightAction", handleMoveRight, false,
		self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterRight)
	ContextActionService:BindActionAtPriority("jumpAction", handleJumpAction, false,
		self.CONTROL_ACTION_PRIORITY, Enum.PlayerActions.CharacterJump)

You can adjust these to rebind some controls, for example on line 120, changing handleMoveForward to handleJumpAction, you'll jump when you press w. But I don't think it is currently possible to bind custom keys to these actions, if that's what you wanted.

---###----------[[SERVICES]]----------###--
local ContextActionService = game:GetService("ContextActionService")



---###----------[[VARIABLES]]----------###--
local DisableMovementAction = "DisableMovement"



---###----------[[LOGIC]]----------###--
ContextActionService:BindActionAtPriority(
	DisableMovementAction,
	---------------
	function()
		return Enum.ContextActionResult.Sink
	end
	---------------
	false,
	Enum.ContextActionPriority.High.Value
	---------------
   	unpack(Enum.PlayerActions:GetEnumItems())
)


ContextActionService:UnbindAction(DisableMovementAction)

1 comment

0

Can you elaborate on how to bind inputs to different actions, say moveBackwardAction?

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