so i made a heli and there is a problem basically whenever i move forward in the heli for some reason the heli goes downwards if i were going backwards the heli goes down as well heres a video showing it:
robloxapp-20210828-1551284.wmv (3.3 MB)
here is my heli code:
local plane = script.Obj.Value
local plrgui = game.Players.LocalPlayer.PlayerGui
local gui = script:WaitForChild("HeliGui")
local vel = plane.Main.BodyVelocity
local BodyGyro = plane.Main.BodyGyro
local inputS=game:getService("UserInputService")
local player=game.Players.LocalPlayer
local seat = script.Parent.Parent
local ControlModule = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule.ControlModule)
local Player = game.Players.LocalPlayer
local max_speed=50
local w,a,s,d,up,dn
local engine = script.Obj.Value.Main
gui.Up.MouseButton1Down:Connect(function()
up = true
end)
gui.Up.MouseButton1Up:Connect(function()
up = false
end)
gui.Down.MouseButton1Down:Connect(function()
dn=true
end)
gui.Down.MouseButton1Up:Connect(function()
dn=false
end)
inputS.InputBegan:Connect(function(input)
local code=input.KeyCode
if code==Enum.KeyCode.E then
up=true
elseif input.KeyCode==Enum.KeyCode.Q then
dn=true
end
end)
inputS.InputEnded:Connect(function(input)
local code=input.KeyCode
if code==Enum.KeyCode.E then
up=false
elseif input.KeyCode==Enum.KeyCode.Q then
dn=false
end
end)
function steer()
while wait() do
local Vector = ControlModule:GetMoveVector()
if Vector.z >= 1 then
s=true
else
s=false
end
if Vector.z <= -1 then
w=true
else
w=false
end
if Vector.x <= -1 then
a=true
else
a=false
end
if Vector.x >= 1 then
d=true
else
d=false
end
end
end
spawn(steer)
local chg=Vector3.new(0,0,0)
local rot=0
local inc=0
while wait(.1) do
local lv=engine.CFrame.lookVector
if up then
if chg.y<30 then
chg=chg+Vector3.new(0,2,0)
end
elseif dn then
if chg.y>-30 then
chg=chg+Vector3.new(0,-2,0)
end
elseif chg.magnitude>1 then
chg=chg*0
else
chg=Vector3.new(0,0,0)
end
if w then
if inc<max_speed then
inc=inc+2
end
vel.Velocity=chg+(engine.CFrame.lookVector+Vector3.new(0,0,0))*inc
BodyGyro.cframe=CFrame.new(engine.Position,engine.Position+Vector3.new(lv.x,-0.3,lv.z))
elseif s then
if inc >-max_speed then
inc=inc-2
end
vel.Velocity=chg+(engine.CFrame.lookVector-Vector3.new(0,0,0))*inc
BodyGyro.cframe=CFrame.new(engine.Position,engine.Position+Vector3.new(lv.x,0.3,lv.z))
else
inc=inc*0.9
vel.Velocity=chg+engine.CFrame.lookVector*inc+Vector3.new(0,0,0)
BodyGyro.cframe=CFrame.new(engine.Position,engine.Position+Vector3.new(lv.x,0,lv.z))
end
if a then
if rot<math.pi/8 then
rot=rot+math.pi/20
end
BodyGyro.cframe=BodyGyro.cframe*CFrame.Angles(0,math.pi/20,rot)
elseif d then
if rot>-math.pi/8 then
rot=rot-math.pi/20
end
BodyGyro.cframe=BodyGyro.cframe*CFrame.Angles(0,-math.pi/20,rot)
else
rot=0
end
end
please help thanks