Zero Out Orientation whilst maintaining heading

I am currently trying to create a Jet that will level out when a function is called.

Currently I can’t seem to get it to revert properly to its current heading, it will often look in a completely different direction than intended

So far i’ve tried multiplying all the orientations by -1 and checked the forums to no avail (maybe i was searching the wrong keywords)

function JetLogic.FlyLevel(RootPart,Time)
	local CurrentSpeed = 250
	local PitchGoal = 0
	local RollGoal = 0

	RootPart.BodyGyro.CFrame = RootPart.BodyGyro.CFrame * CFrame.Angles(0,0,0)
	print("Rotated")
	wait(Time)
end

If you could please give me a general idea of where to look in terms of figuring out this whole issue please do tell, I have CFrame.Angles set to 0,0,0 so its easier to read rather than what I was previously doing with setting everything to * -1.

Currently when you are setting BodyGyro CFrame you are inheriting the rotational properties from RootPart.BodyGyro.CFrame

To fix this just create a new CFrame so you can start with a blank slate of angles, example:

RootPart.BodyGyro.CFrame = CFrame.new(RootPart.BodyGyro.CFrame.Position) * CFrame.Angles(0, 0, 0)

Thanks, I’ll try this. I also found that doing

function JetLogic.FlyLevel(RootPart,Time)
	local x,y,z = RootPart.CFrame:ToOrientation()
	local CurrentSpeed = 250
	local PitchGoal = 0
	local RollGoal = 0

	RootPart.BodyGyro.CFrame = RootPart.BodyGyro.CFrame * CFrame.Angles(0,0,-z)
	wait(1)
	RootPart.BodyGyro.CFrame = RootPart.BodyGyro.CFrame * CFrame.Angles(-x,0,0)
	print("Rotated")
	wait(Time)
end

but it doesnt seem to be the most efficient way to do it anyways.

RootPart.BodyGyro.CFrame = CFrame.new(RootPart.BodyGyro.CFrame.Position) * CFrame.Angles(0, y, 0)

This is what ive done so far with your script, there seems to be a minor issue with the X and Z axis as the X axis is off by -0.2 and the Z axis is off by -0.6. Any ideas for how I could get these 2 to 0?

I believe this is due to the Gyro’s Dampening as I have seen it create a greater innacuracy the more i increase it. Removing the Gyro gets it 100% accurate.