Can you ignore just one axis in a CFrame?

Hi, I’m really new to scripting and I’m trying to make a part move forward relative to what direction the player is facing. It works on all axis’s but I need the CFrame used of the LowerTorso to ignore the Y axis.

here’s the code that’s important:

Object.CFrame = game.Players.LocalPlayer.Character.LowerTorso.CFrame --code from function used for creating the moving part instance
local ForwardForce = Instance.new("VectorForce")
ForwardForce.Parent = workspace:FindFirstChild("Moving Part")
ForwardForce.RelativeTo = Enum.ActuatorRelativeTo.World
ForwardForce.ApplyAtCenterOfMass = true
ForwardForce.Force = workspace:FindFirstChild("Moving Part").CFrame.LookVector * 100

Thanks!

local forward = workspace:FindFirstChild("Moving Part").CFrame.LookVector
ForwardForce.Force = (forward - forward.Y).Unit*100

Tried and it made an error. “attempt to perform arithmetic (sub) on Vector3 and number”

My bad. Replace the second line with this.

ForwardForce.Force = Vector3.new(forward.X, 0, forward.Z).Unit*100

Scripting on mobile is hard

2 Likes

Vectored? you mean Vector3.new?

2 Likes

still the same error “attempt to perform arithmetic (sub) on Vector3 and number”