How to make a spaceship move in the direction it's facing

Here’s the relevant code needed to understand my problem, with bv being a BodyVelocity and bav being a BodyAngularVelocity, both parented to the part/“spaceship”. Rotation works, but the part still moves only moves forward.

uis.InputBegan:Connect(function(input, processed)
	if processed then return end
	if input.KeyCode == Enum.KeyCode.Q then -- MOVING UP
		bv.Velocity = Vector3.new(bv.Velocity.x , 15, bv.Velocity.z)
	end
	
	if input.KeyCode == Enum.KeyCode.W then -- MOVING FORWARD
		bv.Velocity = Vector3.new(bv.Velocity.x , bv.Velocity.y, -15)
	end
	
	if input.KeyCode == Enum.KeyCode.E then -- MOVING DOWN
		bv.Velocity = Vector3.new(bv.Velocity.x, -15, bv.Velocity.z)
	end
	
	if input.KeyCode == Enum.KeyCode.D then -- ROTATING RIGHT
		bav.AngularVelocity = Vector3.new(0, -1, 0)
	end
	
	if input.KeyCode == Enum.KeyCode.A then -- ROTATING LEFT
		bav.AngularVelocity = Vector3.new(0, 1, 0)
	end
end)
3 Likes

Fixed the problem.
Instead of

bv.Velocity = Vector3.new(bv.Velocity.x , bv.Velocity.y, -15)

I did

bv.Velocity = engine.CFrame.lookVector * 15

with engine being the part.

1 Like

What you’re looking for is LookVectors for example,

bv.Velocity = yourObject.CFrame.LookVector * 70 -- 70 is how fast it is
3 Likes

Oh sorry my bad typed out my answer while you were typing yours, Anyway glad you found a solution

1 Like