Changing the default action keys?

Hey everyone! So, I’m creating a platform game where the movement and jump controls are different from their default keys. I’m mainly focused on using the left mouse click to trigger the jump but I can’t seem to find any articles or tutorials on how to change the jump key, or any other movement keys. Does anyone happen to know any good method of achieving this? Anything helps!

3 Likes

You’ll want to read up on ContextActionService. It allows you to bind different input methods to any function, overriding the default controls.

3 Likes

I’d also like to add that it’s possible to make changes to the default movement script if you put the new script into StarterPlayerScripts (in which case the default won’t be added). That way you can reuse the default code and just remap the keys (in case you want to change the movement keys, for example, which may take longer)

1 Like

Unfortunately, there’s no easy way to do this to my knowledge.

-- The code responsible for binding the keys
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)

As you can see, it’s not binding to a specific key, and I’m having difficulty figuring out what PlayerActions are and how to configure them/emulate them.

3 Likes