Hey there Robloxians.
I am currently trying to script a flying-script for a plane. I am only using a small brick to simulate a plane for the time being. - I will just be calling it the "plane brick" from now on.
A bit of information about how the script works: I have a local script that gets the mouse-position (mouse.Hit.p) whenever the player holds "Button1Down" and "mouse.Move". The mouse-position is then sent to the mainscript via a RemoteEvent.
I also have 2 BodyMovers in the "plane brick": a BodyGyro (to rotate the plane) and a BodyVelocity (to generate the speed/ force).
Here is the mainscript:
local part = game.ReplicatedStorage.PlaneBrick:Clone()
part.Parent = game.Workspace
local partPos = part.Position
while wait (0.1) do
script.RemoteEvent.OnServerEvent:Connect(function(player, mousehit) -- "mousehit" is the mouse-position I talked about.
local gyro = part.BodyGyro
gyro.MaxTorque = Vector3.new (math.huge, math.huge, math.huge)
gyro.CFrame = CFrame.new(part.Position, mousehit)
wait(0.5)
part.BodyVelocity.Velocity = part.CFrame.LookVector * 12 -- and this is where my problem is: The script works, but it is not very optimal, since I had to base the BodyVelocity’s direction on the LookVector, I start getting problems when I try to increase the speed. Because whenever I click somewhere, the PlaneBrick will then start rotating, and then a few seconds afterward the PlaneBrick's direction will also change (so they don’t do it synchronously).
--I tried using other alternatives that didn't require the LookVector (So I don’t have to wait for the rotation to be completed, before it can change the direction correctly).
--Here is an example of one of the alternatives I tried, that didn't work:
--part.BodyVelocity.Velocity = Vector3.new (mousehit.x, mousehit.y, mousehit.z ) * 12
--(The position/ direction and speed should both be alright, but for some reason, it doesn't work).
end)
Any help will be very much appreciated :-)

7 comments
Heartbeat doesn't run at thirty frames mate, this depends on the server's performance, which is mostly 50-60fps.
Ah, you're right - stepped/heartbeat are tied to framerate. Answer has been edited to reflect that. Thanks!
Thanks a lot! You are a lifesaver, and a real MVP ;-)
I have a few questions tho: First off, why wasn't it possible to change the BodyVelocity.Velocity, using: “part.BodyVelocity.Velocity = Vector3.new (mousehit.x, mousehit.y, mousehit.z ) * 12” –- as we both had a direction and a speed? Secondly, if the loop now runs 30 to 60 times per second/ each frame. How come that the LookVector doesn’t instantly set an too-early direction -
I've updated my answer
Thanks again! I first saw your answer/edit now, but it still means a lot to me, that you took even more time to further explain it to me! :-)