This is for a plane i am making, which then the mouse is click, the plane follows the mouse, but when Unclicked the plane does not follow the mouse, However when click the plane doesn't wants to follow the mouse and goes 'One' Direction

Anyways on how i can fix this?

(This is a local script in 'planetools' seat)


on = false 
plane = nil
pitch = nil
roll = nil
yaw = nil
mouse = nil
mouseHold = true
Is1Throttling = false
Is2Throttling = false
Throttle1Up = false
Throttle1Down = false
Throttle2Up = false
Throttle2Down = false
heldIcon = 223812423
notHeldIcon = 223812401

player = game.Players.LocalPlayer
GUI = script.Parent:WaitForChild("System_Gui")

script.Parent.Equipped:connect(function(newMouse)
	mouse = newMouse
	plane = script.Parent.Plane.Value
	mouse.Icon = mouseHold and "rbxassetid://"..heldIcon or "rbxassetid://"..notHeldIcon
	mouse.Button1Down:connect(function()
		mouseHold = not mouseHold
		mouse.Icon = mouseHold and "rbxassetid://"..heldIcon or "rbxassetid://"..notHeldIcon
	end)
	mouse.KeyDown:connect(onKeyDown)
	mouse.KeyUp:connect(onKeyUp)
	local xsteer = mouse.X
	local ysteer = mouse.Y
	local mhit = mouse.hit
	mouse.Idle:connect(function()
		local cx = GUI.Absolute.AbsoluteSize.x/2
		local cy = GUI.Absolute.AbsoluteSize.y/2
		if mouseHold == false then
			xsteer = mouse.X
			ysteer = mouse.Y
			mhit = mouse.hit
		else
			xsteer = cx
			ysteer = cy
		end
		pcall(function()
			local xstate = cx-xsteer
			roll = -xstate/cx
			plane.AileronL.A.Motor.DesiredAngle = 1*-roll
			plane.AileronR.A.Motor.DesiredAngle = 1*roll
			local ystate = cy-ysteer
			pitch = -ystate/cy
			plane.ElevatorL.A.Motor.DesiredAngle = 0.25*-pitch
			plane.ElevatorR.A.Motor.DesiredAngle = 0.25*pitch
			plane.PitchWheel.A.Motor.DesiredAngle = 0.25*pitch
			plane.Yokes.A.Motor.DesiredAngle = 0.25*pitch
			plane.Engine.BodyGyro.cframe = mhit*CFrame.fromEulerAnglesXYZ(0,0,-roll) 
		end)
	end)
	game.Workspace.CurrentCamera.CameraType = "Attach"
	GUI.Parent = player.PlayerGui
	GUI.Plane.Value = plane
	GUI.LocalScript.Disabled = false
end)

script.Parent.Unequipped:connect(function()
	mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
	game.Workspace.CurrentCamera.CameraType = "Custom"
	game.Workspace.CurrentCamera.CameraSubject = player.Character.Humanoid
	GUI.LocalScript.Disabled = true
	GUI.Parent = script.Parent
end)

2 comments

0

Don't know if this is the issue, but :connect is depreciated. Use :Connect instead.

0

Alright, i will check that!