Hey can someone help me. With this Problem? Helicopter

You can write your topic however you want, but you need to answer these questions:

  1. I made a Helicopter but I have this problem where when I get in the helicopter and then get out of the helicopter I can’t move or walk. I have searched for this solution but have not found any results.

Video

you can try the game directly
Here
Game Heli

Code LocalScript

local inputS=game:getService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local player=game.Players.LocalPlayer
local engine=script.Parent.Parent

local gyro=engine.BodyGyro
gyro.cframe=engine.CFrame

local spd=engine.BodyVelocity
local max_speed=100

local w,a,s,d,up,dn


inputS.InputBegan:connect(function(input)
	local code=input.KeyCode
	if code==Enum.KeyCode.W or code==Enum.KeyCode.Up then
		w=true
	elseif code==Enum.KeyCode.A or code==Enum.KeyCode.Left then
		a=true
	elseif code==Enum.KeyCode.S or code==Enum.KeyCode.Down then
		s=true
	elseif code==Enum.KeyCode.D or code==Enum.KeyCode.Right then
		d=true
	elseif 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.W or code==Enum.KeyCode.Up then
		w=false
	elseif code==Enum.KeyCode.A or code==Enum.KeyCode.Left then
		a=false
	elseif code==Enum.KeyCode.S or code==Enum.KeyCode.Down then
		s=false
	elseif code==Enum.KeyCode.D or code==Enum.KeyCode.Right then
		d=false
	elseif code==Enum.KeyCode.E then
		up=false
	elseif input.KeyCode==Enum.KeyCode.Q then
		dn=false
	end
end)

function DownS()
	dn=true
end

function KeATAS()
	w=true
end

function KeKiri()
	a=true
end

function Kebawah()
	s=true
end

function KeD()
	d=true
end

function Naik()
	up=true
end

ContextActionService:BindAction("NaikA", Naik, true, Enum.KeyCode.E)
ContextActionService:SetImage("NaikA","http://www.roblox.come/asset/?id=107296839798670")
ContextActionService:SetPosition("NaikA",UDim2.new(0, -131,0, 84))

ContextActionService:BindAction("Down", DownS, true, Enum.KeyCode.Q)
ContextActionService:SetImage("Down","http://www.roblox.come/asset/?id=84184888093806")
ContextActionService:SetPosition("Down",UDim2.new(0, -201,0, 84))


ContextActionService:BindAction("Kiri", KeKiri, true, Enum.KeyCode.A)
ContextActionService:SetImage("Kiri","http://www.roblox.come/asset/?id=109711355906274")
ContextActionService:SetPosition("Kiri",UDim2.new(0, -263,0, 38))


ContextActionService:BindAction("KeDs", KeD, true, Enum.KeyCode.D)
ContextActionService:SetImage("KeDs","http://www.roblox.come/asset/?id=136943086083448")
ContextActionService:SetPosition("KeDs",UDim2.new(0, -13,0, 39))


ContextActionService:BindAction("KeATASs", KeATAS, true, Enum.KeyCode.W)
ContextActionService:SetImage("KeATASs","http://www.roblox.come/asset/?id=82897732186571")
ContextActionService:SetPosition("KeATASs",UDim2.new(0.175, 0,0.175, 0))

ContextActionService:BindAction("Kebawahs", Kebawah, true, Enum.KeyCode.S)
ContextActionService:SetImage("Kebawahs","http://www.roblox.come/asset/?id=115765448733052")
ContextActionService:SetPosition("Kebawahs",UDim2.new(0, -319,0, 38))



local chg=Vector3.new(0,0,0)
local rot=0
local inc=0
while true do
	wait(.1)
	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.9
	else
		chg=Vector3.new(0,1,0)
	end
	if w then
		if inc<max_speed then
			inc=inc+2
		end
		spd.velocity=chg+(engine.CFrame.lookVector+Vector3.new(0,0.3,0))*inc
		gyro.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
		spd.velocity=chg+(engine.CFrame.lookVector-Vector3.new(0,0.3,0))*inc
		gyro.cframe=CFrame.new(engine.Position,engine.Position+Vector3.new(lv.x,0.3,lv.z))
	else
		inc=inc*0.9
		spd.velocity=chg+engine.CFrame.lookVector*inc+Vector3.new(0,2,0)
		gyro.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
		gyro.cframe=gyro.cframe*CFrame.Angles(0,(math.pi/20)+(-math.pi/20*(-inc/150)),rot)
	elseif d then
		if rot>-math.pi/8 then
			rot=rot-math.pi/20
		end
		gyro.cframe=gyro.cframe*CFrame.Angles(0,-(math.pi/20)-(-math.pi/20*(-inc/150)),rot)
	else
		rot=0
	end
end
1 Like

There is no logic to unbind these movement actions after the player leaves the helicopter.

local function onPlayerLeavingHelicopter()
	w, a, s, d, up, dn = false, false, false, false, false, false

	ContextActionService:UnbindAction("NaikA")
	ContextActionService:UnbindAction("Down")
	ContextActionService:UnbindAction("Kiri")
	ContextActionService:UnbindAction("KeDs")
	ContextActionService:UnbindAction("KeATASs")
	ContextActionService:UnbindAction("Kebawahs")
end
1 Like

yeah that’s it /: and Thanks for your help

1 Like

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