A better helicopter

I am writing a roblox lua script . It is a Local Script of a helicopter . The helicopter can bend front and back to go forward and backward , it can also yaw left and right . Can anyone edit it so that it can also bend left and right to go left and right ?
Here is the script :

local InputService = game:getService(“UserInputService”)
local replicatedstorage = game:GetService(“ReplicatedStorage”)
local remote = replicatedstorage:WaitForChild(“HelicopterEvent”)
local player=game.Players.LocalPlayer

---

local Engine=script.Parent.Engine
local Rotor1=script.Parent.Motor
local Rotor2=script.Parent.Rotor
local Configuration=script.Parent.Configuration
local Gyro=Engine.Direction
local Thrust=Engine.Thrust

local MaxLift=Configuration.MaxLift.Value
local LiftAcceleration=Configuration.LiftAcceleration.Value

local MaxSpeed=Configuration.MaxSpeed.Value
local Acceleration=Configuration.Acceleration.Value

local MaxTurn=Configuration.MaxTurn.Value
local TurnSpeed=Configuration.TurnSpeed.Value

local MaxRoll=Configuration.MaxRoll.Value
local RollSpeed=Configuration.RollSpeed.Value

local w,s,a,d,e,q,x,z

function StartUp()
remote:FireServer(“StartUp”)
end

---

InputService.InputBegan:connect(function(Input)
local code=Input.KeyCode
local EngineOn=Configuration.EngineOn.Value
local Starting=Configuration.Starting.Value
if EngineOn == true then
if code==Enum.KeyCode.W or code==Enum.KeyCode.Up then
s=false
w=true
elseif code==Enum.KeyCode.S or code==Enum.KeyCode.Down then
w=false
s=true
elseif code==Enum.KeyCode.A or code==Enum.KeyCode.Left then
d=false
a=true
elseif code==Enum.KeyCode.D or code==Enum.KeyCode.Right then
a=false
d=true
elseif code==Enum.KeyCode.E then
q=false
e=true
elseif code==Enum.KeyCode.Q then
e=false
q=true
elseif code==Enum.KeyCode.Z then
x=false
z=true
elseif code==Enum.KeyCode.X then
z=false
x=true
end
elseif EngineOn == false and code==Enum.KeyCode.E then
if Starting == false then
StartUp()
end
end
end)

---

InputService.InputEnded:connect(function(input)
local code=input.KeyCode
if code==Enum.KeyCode.W or code==Enum.KeyCode.Up then
w=false
elseif code==Enum.KeyCode.S or code==Enum.KeyCode.Down then
s=false
elseif code==Enum.KeyCode.A or code==Enum.KeyCode.Left then
a=false
elseif code==Enum.KeyCode.D or code==Enum.KeyCode.Right then
d=false
elseif code==Enum.KeyCode.E then
e=false
elseif input.KeyCode==Enum.KeyCode.Q then
q=false
elseif code==Enum.KeyCode.Z then
z=false
elseif input.KeyCode==Enum.KeyCode.X then
x=false
end
end)

---

local Lift=Vector3.new(0,0,0)
local rot=0
local TargetSpeed=0
local TargetRoll=0
while true do
wait(.1)
local LookVector=Engine.CFrame.lookVector

if e then
–rotorSpd(0.6)
if Lift.Y < MaxLift then
Lift=Lift+Vector3.new(0,LiftAcceleration,0)
end
elseif q then
–rotorSpd(0.2)
if Lift.Y >- MaxLift then
Lift=Lift-Vector3.new(0,LiftAcceleration,0)
end
else
–rotorSpd(0.4)
Lift=Vector3.new(0,0,0) --Speed when not pressing E or Q
end

if w then
if TargetSpeed-MaxSpeed then
TargetSpeed=TargetSpeed-Acceleration
end
Thrust.velocity=Lift+(LookVector-Vector3.new(0,0.3,0))<em>TargetSpeed
Gyro.cframe=CFrame.new(Engine.Position,Engine.Position+Vector3.new(LookVector.x,0.3,LookVector.z))
else
TargetSpeed=TargetSpeed</em>0.9
Thrust.velocity=Lift+LookVector*TargetSpeed+Vector3.new(0,0,0)
Gyro.cframe=CFrame.new(Engine.Position,Engine.Position+Vector3.new(LookVector.x,0,LookVector.z))
end

if z then
–Please add something here
elseif x then
–Please add something here
else
–Please add something here
end

–Please also modify the formula below
if a then
if rot<math.pi/8 then
rot=rot+math.pi/20
end
Gyro.cframe=Gyro.cframe<em>CFrame.Angles(0,math.pi/10,rot)
elseif d then
if rot>-math.pi/8 then
rot=rot-math.pi/20
end
Gyro.cframe=Gyro.cframe</em>CFrame.Angles(0,-math.pi/10,rot)
else
rot=0
end
end
1 Like

This would most likely be too much work, or would take too long, because it’s over the devforum and we don’t know how your game works. What have you tried so far?

1 Like

The problem lies on the last lines , it only consides the left ,right yaw and the forward and backward function but not left and right sideways

if a then
if rot<math.pi/8 then
rot=rot+math.pi/20
end
Gyro.cframe=Gyro.cframe<em>CFrame.Angles(0,math.pi/10,rot)
elseif d then
if rot>-math.pi/8 then
rot=rot-math.pi/20
end
Gyro.cframe=Gyro.cframe</em>CFrame.Angles(0,-math.pi/10,rot)
else
rot=0
end
end

I’m 99% sure the scripting support category is for helping solve issues with your scripts instead of requesting people to add additional lines of code to a script inside of a free model helicopter without any further information about how the helicopter functions.

If you’re going to request for someone to make a script for you find someone and pay them for it because I’m positive nobody is going to write this for you with nothing in return.

It scares a lot of people away when you have unformatted code. Even though one could easily format it for theirself, it comes off as not being worth it in any way.

1 Like

Well , here is how my code works ,

First , it makes the control input work when engine is running and denies input when engine is off .

Second , it will make variables of W,S,A,D,E,Q (they represent if we are going forward , backward , Yaw left , Yaw right , Up , Down)(Z and X is roll left and roll right to go left and right , they are not working now) true if they are pressed(If engine is off then pressing E will start engine) .

Third , it makes input variables false when Input ends

4.It will define how much the helicopter should move (how much Lift , rot , target speed and target roll) when variables WSADEQZX are true or false (in vector 3)They will be considered together

Finally , below “Please also modify the formula below” , it will have the function to consider the value of Direction and Thrust which is a BodyGyro and BodyVelocity


The problem is that i dont know how to consider the value of “Direction” and “Thrust” to roll left and right