Hello, Ive come across a problem with the flight system I am trying to make, for some reason, when I fly the plane upwards it bugs out and starts jittering. Evidence:
Code:
local GroundParams = RaycastParams.new()
GroundParams.FilterDescendantsInstances = {Plane}
GroundParams.FilterType = Enum.RaycastFilterType.Blacklist
local Size = Plane.Size
Mouse.TargetFilter = workspace.Fighters
local MousePos = Mouse.hit.p
local MouseCF = Mouse.Origin
local Target = Plane.Position + ((MousePos - Plane.Position).Unit * 100)
local Left = Plane.CFrame * CFrame.new(-Size.X/2, 0, 0).p
local Right = Plane.CFrame * CFrame.new(Size.X/2, 0, 0).p
local CheckVar = (Target - Plane.Position).Magnitude
local FCheckVar = Plane.CFrame * CFrame.new(0, 0, -CheckVar).p
local RotationalVar = ((FCheckVar - Target).Magnitude / 8)
local LeftPoint = (Target - Left).Magnitude
local RightPoint = (Target - Right).Magnitude
local ForwardThrust = Plane.CFrame.LookVector * Speed -- + Vector3.new(0, Drag, 0)
----Stalling-----------
Plane.Thrust.Velocity = ForwardThrust
----------Banking
if Plane.AssemblyLinearVelocity.Magnitude > 100 then
if LeftPoint < RightPoint and LeftPoint > RotationalVar and LeftPoint < 300 then
Plane.BodyGyro.CFrame = Mouse.Hit * CFrame.Angles(0,0,math.rad(Plane.AssemblyAngularVelocity.Y * 30))
elseif LeftPoint > RightPoint and RightPoint > RotationalVar and RightPoint < 300 then
Plane.BodyGyro.CFrame = Mouse.Hit * CFrame.Angles(0,0,math.rad(Plane.AssemblyAngularVelocity.Y * 30))
else
Plane.BodyGyro.CFrame = MouseCF
end
end
end)```
All the help will be really appreciated!