I’m working on a 2D platformer project, where the player has to constantly parkour/climb ladders to progress. However, I have ran into a brick wall whilst trying to make the player only move left-to-right. I am planning to create a custom character controller for this, but how can I achieve the title of this post (without setting the walkspeed to zero) with just a script?
I think you’re better off just making that custom character controller. But if you wanna make it so that the player can only walk left-right, you can disable specific movement keys like so:
local ContextActionService = game:GetService("ContextActionService")
local keysToDisable = {Enum.KeyCode.W, Enum.KeyCode.S}
local function callback()
return Enum.ContextActionResult.Sink
end
ContextActionService:BindActionAtPriority(
"DisableMovement",
callback,
false,
Enum.ContextActionPriority.High.Value,
unpack(keysToDisable)
)
If you wanna stop the player completely without setting the WalkSpeed to zero while still maintaining the MoveDirection, you could probably just freeze the player in place with some sort of body mover like AlignPosition.
^ Mobile controls:
Yeah this wouldn’t work very well with a joystick
In this case you should make your own little UI that only lets the player move left and right like a d-pad.
By the way, I figured out that I just needed a plane constraint.
Forgot those existed
You might as well set your own reply as solved now in case someone else has the same issue as you