I am making a game where a random player is selected to drive a helicopter and drop bombs on the other players I made it so the helicopter turns left and right just fine but I don’t know how to make the helicopter go forwards and backwards here is my code:
Local Script
uis.TextBoxFocused:Connect(function()
isInChat = true
end)
uis.TextBoxFocused:Connect(function()
isInChat = false
end)
uis.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.W and isInChat == false then
inputEvent1:FireServer()
end
if inp.KeyCode == Enum.KeyCode.S and isInChat == false then
helicopterControlsEvent2:FireServer()
end
if inp.KeyCode == Enum.KeyCode.A and isInChat == false then
helicopterControlsEvent3:FireServer()
end
if inp.KeyCode == Enum.KeyCode.D and isInChat == false then
helicopterControlsEvent4:FireServer()
end
end)
Server Script
local function front()
local helicopter = game:GetService("Workspace"):WaitForChild('HelecopterModel')
helicopter.AssemblyLinearVelocity = helicopter.CFrame.LookVector * 35
end
local function back()
local helicopter = game:GetService("Workspace"):WaitForChild('HelecopterModel')
end
local function left()
local helicopter = game:GetService("Workspace"):WaitForChild('HelecopterModel')
helicopter:PivotTo(helicopter:GetPivot() * CFrame.Angles(0, math.rad(10), 0))
end
local function right()
local helicopter = game:GetService("Workspace"):WaitForChild('HelecopterModel')
helicopter:PivotTo(helicopter:GetPivot() * CFrame.Angles(0, math.rad(-10), 0))
end
helicopterControlsEvent4.OnServerEvent:Connect(right)
helicopterControlsEvent3.OnServerEvent:Connect(left)
helicopterControlsEvent2.OnServerEvent:Connect(back)
helicopterControlsEvent1.OnServerEvent:Connect(front)
Thanks.