-- This finds the Aircraft that we are controlling

Parts = game.Players.LocalPlayer:FindFirstChild("Turret").Value;
VehicleStats = Parts.Stats;
local Settings = require(Parts.Parent.VehicleSettings)

function move(point, engine)
	local origincframe = engine:findFirstChild("BodyGyro").cframe
	local size = engine.Parent.Parent:GetExtentsSize()
	local target = engine.Position+((point - engine.Position).unit*100)
	local dir = (target - engine.Position).unit
	local spawnPos = engine.Position
	local left = engine.CFrame*CFrame.new(-size.x/2, 0, 0).p
	local right = engine.CFrame*CFrame.new(size.x/2, 0, 0).p
	local md = (target - engine.Position).magnitude

	local foebmd = engine.CFrame*CFrame.new(0, 0, -md).p
	local toleft = (target -left).magnitude
	local toright = (target -right).magnitude
	local rot = ((foebmd - target).magnitude/10)
	local pos = spawnPos + (dir * 1)
	local turn = math.rad((rot/10)*Settings.TiltFactor)
	if turn > math.rad(89) then
	turn = math.rad(89)
	end
	if toleft< toright and toleft >rot then
		engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos,  (pos + dir))*CFrame.fromEulerAnglesXYZ(0, 0, turn)
	elseif toleft > toright and toright >rot then
		engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos,  (pos + dir))*CFrame.fromEulerAnglesXYZ(0, 0, -turn)
	else
		engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos,  -(pos + dir))
	end
	engine:findFirstChild("BodyGyro").P = Settings.TurnSpeed
end

function onMouseMove(mouse)
	