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