How would I make my helicopter model go forwards/backwards? (UNSOLVED)

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.

you can set the velocity like you are, just make sure to reset it to 0 once the key is released. and for going backwards you just do the negative of lookvector or something

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.