Ok, so I want to make my plane fly in a perfectly straight line when it is not being used, but i am running into an issue with that, this video shows what is happening:
And here is my code:
--(FlyNoClicking is the event that you should look at)--
script.Parent.VehicleEvent.OnServerEvent:Connect(function(Player, Event, Arguments)
if Event == "FlyTo" then
local MouseHit = Arguments[1]
local Vehicle = Arguments[2]
for _, Part in pairs(Vehicle:GetDescendants()) do
pcall(function()
Part:SetNetworkOwner(nil)
end)
end
local LookAt = CFrame.lookAt(Vehicle.PrimaryPart.Position, MouseHit)
local LookAtLerp = Vehicle.PrimaryPart.CFrame:Lerp(LookAt, 0.05)
Vehicle:SetPrimaryPartCFrame(LookAtLerp)
local Velocity = Vehicle.PrimaryPart.CFrame.LookVector * 55
Vehicle.PrimaryPart.Velocity = Velocity
end
if Event == "FlyToNoClicking" then
local Vehicle = Arguments[1]
for _, Part in pairs(Vehicle:GetDescendants()) do
pcall(function()
Part:SetNetworkOwner(nil)
end)
end
local Velocity = Vehicle.PrimaryPart.CFrame.LookVector * 55
Vehicle.PrimaryPart.Velocity = Velocity
end
end)
Again, how can I make it so the plane does not drop when it isnt being clicked, thanks for any help!