Can't fly up and down [Works on baseplate but not on different place]? (Press E or Q)

So I made a UFO got it from toolbox. And its completely drivable and working fine. My friend scripted it for me. I did the functions and he did the drive movements. So get to the point, it is working perfectly fine as intended, you can drive it fly up and down. It works similar to Jailbreak but exactly as Jailbreak. RobloxScreenShot20200118_191626057

Alright so I created the airvehicle in an baseplate for testing because I am gonna put it on my game. Which means a different place. So I created this airvehicle thing working fine in the baseplate. But something didn’t go right, when I was playing with the vehicle in the baseplate its fine. I can fly up and down. But when I put it on a different place which is my game, I tried it, I can drive it like turning left and right and moving forward and backwards. And then when I tried to fly it up, It won’t fly no matter what same with fly down. I do not know what’s causing the problem. I just don’t get it, when I fly up and down in the baseplate it works but when I tried it on a different place, it won’t.

I tried seeking help from my friends, but they don’t know what’s causing the problem. I tried searching the solution on some topics and on the internet. But I have no luck of solution. Instead I have to create this topic.

How this airvehicle works?

When I enter the vehicle by walking through the body to the driveseat which means everything in the UFO is not collidable except the driveseat. When I sit, a script detects whenever someone sits and gets out. When I sit, the control script will be cloned and parented to my PlayerGui (the control script is a localscript). When I get off, the localscript inside my PlayerGui which is the control will be destroyed. That’s how my vehicle works, its simple.

Here are codes:

LOCALSCRIPT CODE (Controls Script):

--Localscript
local ContextActionService = game:GetService("ContextActionService")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local plane = script.Obj.Value

local RunService = game:GetService("RunService")
local height = 0
local turn = 0
local moving = 0
local Tilt = 0


local MoveRightKeyDown = false
local MovetLeftKeyDown =false

local vel = plane.Main.BodyVelocity
local tru = plane.Main.BodyForce
local BodyGyro = plane.Main.BodyGyro

local speed = 20

function MoveUp(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		height = 50
	end
	if action_state == Enum.UserInputState.End then
		height = 0
	end
end

function MoveDown(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		height = -50
	end
	if action_state == Enum.UserInputState.End then
		height = 0
	end
end

function MoveLeft(action_name, action_state)
	MovetLeftKeyDown = false
	if action_state == Enum.UserInputState.Begin then
MovetLeftKeyDown = true
	while MovetLeftKeyDown do
		wait(0.1)
		turn = turn + 10
	end
	 elseif action_state == Enum.UserInputState.End then
      MovetLeftKeyDown = false
end

end



function MoveRight(action_name, action_state)
	MoveRightKeyDown = false
	if action_state == Enum.UserInputState.Begin then
MoveRightKeyDown = true
	while MoveRightKeyDown do
		wait(0.1)
		turn = turn - 10
end
	 elseif action_state == Enum.UserInputState.End then
      MoveRightKeyDown = false
end

end

function MoveForward(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		moving = -2700
		 Tilt = -10
	end
	if action_state == Enum.UserInputState.End then
		moving = 0
		 Tilt = 0
	end
end

function MoveBackwards(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		moving = 2700
		 Tilt = 10
	end
	if action_state == Enum.UserInputState.End then
		moving = 0
		Tilt = 0
	end
end



RunService:BindToRenderStep("Update", Enum.RenderPriority.Input.Value, function()
	
	BodyGyro.CFrame = CFrame.Angles(0, math.rad(turn), 0) * CFrame.Angles(math.rad(Tilt), 0, 0)
	tru.Force = plane.Main.CFrame.LookVector * (-moving * 2 )
	vel.Velocity = Vector3.new(0,height,0)
	
end)

ContextActionService:BindAction("Down", MoveDown, false, Enum.KeyCode.Q)
ContextActionService:BindAction("Up", MoveUp, false, Enum.KeyCode.E)
ContextActionService:BindAction("Left", MoveLeft, false, Enum.KeyCode.A)
ContextActionService:BindAction("Right", MoveRight, false, Enum.KeyCode.D)
ContextActionService:BindAction("Forward", MoveForward, false, Enum.KeyCode.W)
ContextActionService:BindAction("Backwards", MoveBackwards, false, Enum.KeyCode.S)

plane.DriverSeat.ChildRemoved:Connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") then
		ContextActionService:UnbindAction("Down")
		ContextActionService:UnbindAction("Up")
		ContextActionService:UnbindAction("Left")
		ContextActionService:UnbindAction("Right")
		ContextActionService:UnbindAction("Forward")
		ContextActionService:UnbindAction("Backwards")
	end	
end)

NORMAL SCRIPT CODE (Detects when player sits or gets off the vehicle):

--Script
local driverseat = script.Parent
local main = script.Parent.Parent.Main
local plane = script.Parent.Parent


driverseat.ChildAdded:connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") then
		--Sitz ist belegt
		if child then
			--Get the sitting player
			player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
			
			if player then
				--Sets ownership to player
				--driverseat:SetNetworkOwner(player)
				--print(player.Name.." has Networkownership")
				driverseat.DoorOpen:Play()
				driverseat.DoorOpen.Ended:Wait()
				driverseat.DoorClose:Play()
				driverseat.DoorClose.Ended:Wait()
				wait()
				script.Parent.Parent.Body.Body.Running:Play()
				for i = 1,100 do
					script.Parent.Parent.Body.Body.Running.PlaybackSpeed = script.Parent.Parent.Body.Body.Running.PlaybackSpeed + .01
					wait()
				end				
				local localCarScript = script.HelicopterChassis:Clone()
				localCarScript.Parent = player.PlayerGui
				localCarScript.Obj.Value = plane
				print("Localscript was inserted")			
			end
		end	
	end
end)

driverseat.ChildRemoved:Connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") then
		print("Localscript deleted...")
		player.PlayerGui:WaitForChild("HelicopterChassis"):Destroy()
		wait()
		script.Parent.Parent.Body.Body.Running:Play()
		for i = 1,100 do
			script.Parent.Parent.Body.Body.Running.PlaybackSpeed = script.Parent.Parent.Body.Body.Running.PlaybackSpeed - .01
			wait()
		end		
		script.Parent.Parent.Body.Body.Running:Stop()	
	end
end)

That’s the full code! However, I do not know what I am doing wrong in the entire code. I use ContextActionService for the hotkeys. You know, they buttons what make the airvehicle work.

Example:

ContextActionService:BindAction("Forward", MoveForward, false, "w") -- MoveForward is a function just without ()

If you got any suggestions to fix this problem? Let me know down in the replies. Got ideas? Suggest it to me. You have something to add in my code? Reply me :slightly_smiling_face:

Thanks in advance!

1 Like

Is the ufo accidentally welded to the basepart?,

1 Like

Actually I have a lot of WeldConstraints welding everything that the body of the UFO has.
WeldFile

All Part0 of those WeldConstraints are the DriveSeat always. While the Part1 is the parts in the body.

1 Like

Weird, could you share the place? Maybe I’ll figure it out

1 Like

Alright I will later edit this when i wake up because its late night at my country. The problem is: It works on baseplate but on different place it wont fly up and down.

In a few hours i edit this with a file.

UPDATE:

Alright here is the place file. It’s not just only UFO that has problems but also with other helicopters! Here is the place file: TestPlace.rbxl (296.7 KB)

1 Like

Thanks I’ll check it out tomorrow as well due to timezone

1 Like

Right heres the place file: TestPlace.rbxl (296.7 KB)

1 Like

So I tested the place and I am able to fly up/down aswell as turn and aswell as drive forward. But the driving forward is weird because you can only fly forward if you’re 90 degrees turned.

1 Like

Ignore that driving forward, I will take care of it. The problem is when you put it on a different game/place when you try it, you won’t be able to fly up and down. See for your self. I don’t know what’s causing it. Or its a bug or just straight up problem.

I took some time to test this and it seems to be working fine for me, are there any errors in the console when you experience the issue?

2 Likes

The issue is when you use the ufo in a different place you cant fly it up and down by pressing e and q

hmm…i can’t seem to replicate the issue could you possibly provide a video snippet or repro of what is going on?

1 Like

Alright the problem isn’t big that much. I tried putting the UFO on a grass place. You know, a template. I tried it, i can fly up by pressing E.

Maybe its not working properly on a specific place.

I meant are there errora in the console when you cant fly it. You can find the console by pressing F9 ingame

Theres no error popping up in the console. Even in the output theres no error popping up. I don’t whats wrong with the air vehicle. I tested it on baseplate, no errors showing. I tested it on another template which there are mountains and grass, no errors are showing. I tested it on my game, no errors showing but I can’t fly up.

Are you sure theres no mechanical issue (for examplw with your hardware as in keyboard)? Can you send me the script so i can see if theres any issue im on phone right now

1 Like

My computer is fine. Plus the whole code is in the question. In the very top.