How do I make a plane fly where my mouse is looking?

But my Direction is a three-digit value: 0.29635337, 0.864617527, 0.405723006. How do I make it work?

1 Like

Try doing:

BodyGyro.CFrame = CFrame.Angles(0.29635337, 0.864617527, 0.405723006)

I forgot to say, this is the value of my mouse, and it always changes. (I pass it via remote function) trying to write a 3 value in parentheses results in: Unable to cast Vector3 to float

I also thought so at first, but it works even when I don’t click.

local Direction = (Mouse.Hit.Position - Character.Head.Position).unit
BodyGyro.CFrame = CFrame.Angles(Direction)

Argument 3 missing or nil
How do I fix this?

You have to unpack the components of the Direction vector.

BodyGyro.CFrame = CFrame.fromOrientation(Direction.X, Direction.Y, Direction.Z)

Or better yet:

BodyGyro.CFrame = CFrame.new(Vector3.new(0, 0, 0), Direction)
3 Likes

Thanks, it worked, but it didn’t solve my problem with flying :frowning: There have a video above about how my plane flies, the problem has been solved a little, but mostly everything remains as it was. How do I make my plane turn a little slower and more correctly? (My plane is twitching strangely)

My problem is only half solved… I used local Direction = Camera:ScreenPointToRay(Mouse.X, Mouse.Y, 0). Now I can fly a plane, but only in the first person, if I start. control from the 3rd person, my plane turns over on the Z axis so that my head is on the bottom. How do I solve this?

Probably lock a person to first person when he sits on the plane and then unlock it back if he gets off?

Edit:
I first thought of this just because flying in the plane in 1st person is cool.

Is there any other way to rotate a part other than bodygyro? I found some bug when I get into my plane, it turns itself in the opposite direction. And when I fly it is not because of what just flips the plane. I tried using orientation and rotation but nothing helps me. (I want to be able to fly in first person and third person)

FYI. Not sure if there’s another fix - But there’s an issue with Flight following the mouse that occurs when the mouse is over the Plane // Object.

The only fix I know is to Parent the Plane to the Player piloting it.

What I’ve come up with for my space ships is moving them with a Object.CFrame = Object.CFrame * CFrame.new(0,0,Speed) to make it move forward (If it goes backward simply change the Speed to -Speed) and CFrame.Angles(Pitch, Turn, Rotate) to make it rotate, pitch and turn accordingly. Now to get the Pitch and Turn values I use a UserInputService.InputChanged connection like this:

UserInputService.InputChanged:Connect(function(inputObject, GPE)
	local Vector = Vector2.new(inputObject.Position.X/Camera.ViewportSize.X * 2 - 1,
		inputObject.Position.Y/Camera.ViewportSize.Y * 2 - 1)*-Handling
	if math.abs(Vector.Magnitude) >= Deadzone then -- Define a deadzone, can be 0 if you want no deadzone.
		Pitch = Vector.Y
		Turn = Vector.X
	else
		Turn = 0
		Pitch = 0
	end
end)

Then run the CFrame change on a RunService.Heartbeat connection and use the DeltaTime argument like said in this thread and you’re good to go!
Please note I haven’t spent the full time to read this entire thread, but from the looks of it this is much simpler than whatever you are currently doing.
Hopefully this helps!

2 Likes

I will answer if It help me, thanks you.

how do I do this? Can you write this please?

So it’ll be something like:
Forgive lack of indent, this was written solely from memory as I’m away from ROBLOX atm.

PilotSeat.Changed:Connect(function(Property)
    if Property == "Occupant" then
    local Humanoid = PilotSeat.Occupant
    if Humanoid then
    Plane.Parent = Humanoid.Parent
    else
    Plane.Parent = game:GetService("Workspace") 
    end
    end
    end)
1 Like

Was this ever solved?

Working on something similar.

Still not solved. I gave it up because I couldn’t find a solution for a very long time

try getting scripts from roblox rocket ship gear
it allows u to go anywhere where your mouse is at

Body Movers like Body velocity and Body gyro can help.

sorry to bump this, but try looking at Crazyman32’s biplane model here

I tried it out and it has mouse guidence, also will keep plane from flying upside down lol

1 Like