Math problem with body velocity

I want to have a drone that flies with WASD and QE to move down and up.
I have everything except the part where it changes the velocity of the drone.

if uis:IsKeyDown(Enum.KeyCode.W) then
	module.Thrust = Vector3.new(0, 0, -1)
elseif uis:IsKeyDown(Enum.KeyCode.S) then
	module.Thrust = Vector3.new(0, 0, 1)
else
	module.Thrust = Vector3.new(0, 0, 0)
end
			
if uis:IsKeyDown(Enum.KeyCode.A) then
	module.Thrust = Vector3.new(1, 0, module.Thrust.Z)
elseif uis:IsKeyDown(Enum.KeyCode.D) then
	module.Thrust = Vector3.new(-1, 0, module.Thrust.Z)
else
	module.Thrust = Vector3.new(0, 0, module.Thrust.Z)
end
			
if uis:IsKeyDown(Enum.KeyCode.Q) then
	module.Thrust = Vector3.new(module.Thrust.X, -1, module.Thrust.Z)
elseif uis:IsKeyDown(Enum.KeyCode.E) then
	module.Thrust = Vector3.new(module.Thrust.X, 1, module.Thrust.Z)
else
	module.Thrust = Vector3.new(module.Thrust.X, 0, module.Thrust.Z)
end
			
module.Drone.Gyro.CFrame = CFrame.new(
	module.Drone.Core.Position,mouse.Hit.p
)
local look = module.Drone.Core.CFrame.lookVector
module.Thrust = module.Thrust * module.Settings.Speed
module.Drone.Velocity.Velocity = Vector3.new(module.Thrust * look.X, module.Thrust.Y * look.Y, module.Thrust.Z * look.Z)
1 Like
path.to.part.CFrame = path.to.part.CFrame * module.Drone.Velocity.Velocity

Also, I would suggest some movement damping as directly just setting the velocity can feel rather snappy and clunky to control to the player. Assuming this loop is tied to heartbeat (1/60th of a second) Something like this might help:

local TURN_AROUND_TIME = 1 -- ideal amount of seconds to go from full thrust forward to full thrust back
if uis:IsKeyDown(Enum.KeyCode.W) then
	module.Thrust = Vector3.new(module.Thrust.X, module.Thrust.Y, module.Thrust.Z-TURN_AROUND_TIME/30)
elseif uis:IsKeyDown(Enum.KeyCode.S) then
	module.Thrust = Vector3.new(module.Thrust.X, module.Thrust.Y, module.Thrust.Z+TURN_AROUND_TIME/30)
else
	module.Thrust = Vector3.new(module.Thrust.X, module.Thrust.Y, module.Thrust.Z - (TURN_AROUND_TIME/30 and module.Thrust.Z > 0 or -TURN_AROUND_TIME/30))
end
--etc...