How do I prevent the player from being moved on an axis?

Hey! I’m making a side scroller game and I’ve been trying to figure out how to prevent the player from being able to move on a certain axis. I’ve tried using BodyVelocity (never had experience with this) but it just seems to halt the player completely.

local Root = player.Character.HumanoidRootPart
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(100000, 100000, 0)
BV.Velocity = Vector3.new(0,0,0)
BV.Parent = Root

I’m trying to lock the player on the ‘Z’ Axis.

If you put a higher number on MaxForce it will actually halt the player from that axis, so you should only put a higher force on the Z axis:

local Root : Instance = player.Character.HumanoidRootPart
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(0, 0, 40000)
BV.Velocity = Vector3.new(0,0,0)
BV.Parent = Root
2 Likes