Hey devs, I have tried to make my plane follow my mouse using run service and then CFrame’ing the part (plane) to follow my mouse position every frame, but its too fast and laggy looking.
Code for CFrame’ing it every frame:
Remote.OnServerEvent:Connect(function(player, mouse)
local BasePos = Base.Position -- the plane
Base.CFrame = CFrame.new(BasePos, Vector3.new(mouse.X, mouse.Y, mouse.Z))
end)
How could I make the part follow the mouse smoothly? Perhaps there’s a more efficient way of doing this?
The problem isn’t because of network conflict between the Client and server, the problem is the fact that its moving too fast per frame because of CFrame’ing it every frame.
I’m asking if there’s a more efficient way to make the plane (part) follow the mouse.
I have thought about that, but that wouldn’t align the plane with the mouse’s orientation since the mouse doesn’t have orientation…
My code:
-- remote is being fired every frame the player is in the plane
Remote.OnServerEvent:Connect(function(player, mouse)
local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Attachment1 = mouse
AlignOrientation.Attachment0 = Base -- plane
end)
I get this error: Unable to assign property Attachment1. Object expected, got Vector3
You need to make an attachment parented to terrain and then set that attachment’s position to the position of the mouse. You only need to create the AlignOrientation/Position once, not every time you call the remote.
This works, but how can I change the Attachment’s orientation so the plane’s orientation will also change.
As you can see in the video, the attachment is following the mouse position but the plane is not taking on any new orientation, only when I manually change the orientation of the attachment using the Rotate tool the plane follows the orientation of the attachment.
This worked, I set the attachments CFrame to equal Mouse.Hit, although the problem still persists, the actual flying is very sensitive and unpredictable.
I’m using LinearVelocity for the upward and forward movement.
i think you should use tweenservice for this, it makes things very smooth trust me
heres a post on the roblox doc about tweenservice TweenService | Roblox Creator Documentation