Help with Plane

Hi! I kinda finished this plane I made that you can change the direction via mouse and press the W key to move forward. But… it doesn’t move smoothly. This is the game: (1) Untitled Game - Roblox
Everytime you fly the plane, it has to glitch out. Is there a way I can fix this?
Code to make the plane look in the direction of the mouse:

local plane = workspace.Model.PlaneWalls.PlaneBody
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local mouseActive = game.StarterPlayer.StarterPlayerScripts.FollowMouse.Disabled == true
local seat = workspace.Model.VehicleSeat
seat.ChildAdded:connect(function()
	local Sit = player.Character.Humanoid.Sit
	if Sit == true then
		print("The player just sat down.")
		mouse.Move:connect(function()
			if mouseActive == false then
				local mousePosition = mouse.Hit.p
				plane.CFrame = CFrame.new(plane.CFrame.p,mousePosition)
			end
		end)
	else
		print("The player is no longer seated.")
	end
end)

Thanks.

1 Like

I would try to replace the mouse.Move:Connect(function() with a while loop

while game:GetService("RunService"):Wait() do
if mouseActive == false then
				local mousePosition = mouse.Hit.p
	plane.Velocity =CFrame.new(plane.Cframe,mouse).lookVector * 50
				if mousePosition.plane.PlaneWalls:GetChildren() then
					mouseActive = true
					wait(1)
					mouseActive = false
				end
			end
end

The game gives me a “Wait is not a valid member of RunService “Run Service”” whenever the script is run. I think you did something wrong in the code, @StraightScared.

Try replacing it with:

game:GetService("RunService").RenderStepped:Wait()

That breaks everything. So does StraightScared’s script.