Make Player Walk to the cursor but only on X-Axis

Hello. I already have the code but I don’t know exactly how to make the player walk on X axis only.


HRP.CFrame = CFrame.lookAt(HRP.CFrame.Position,, HRP.CFrame.Position.Y, Mouse.Hit.Position.Z))

Humanoid:MoveTo(Mouse.Hit.Position) -- I only need the X-axis.


Do Mouse.Hit.Position.X to achieve it.

Thanks for the idea. However, it gave me an error “Unable to cast double Vector3”. I already fixed it by doing this.

Humanoid:MoveTo(, 0, HumanoidRootPart.CFrame.Position.Z))


Well, for a click to move, just do Humanoid:MoveTo(Mouse.Hit.Position.X, HumanoidRootPart.Crame.Y, Mouse.Hit.Position.Z)
idk why u would want to do this but your choice

1 Like

I am making a 2D kind of game so I only need the X axis for the player to move. I don’t want the players to go towards the camera while moving their characters with their mouse.