How to Rotate a part with BodyGyro with CFrame and Vector3

I want to rotate a part with BodyGyro, and be able to change the existing orientation with a new Vector3. For example: BodyGyro.CFrame = CFrame.new(Part.Orientation + Vector3.new)

What I’ve written done so far doesn’t work.

I’ve looked and couldn’t find anything relevant to my issue on the Dev Hub. This is what I have written:

function forwardpitch()
	BodyGyro.CFrame = CFrame.new(MainTank.Orientation + Vector3.new(math.rad(0), math.rad(0), math.rad(-0.05)))
end

function backwardpitch()
	BodyGyro.CFrame = CFrame.new(MainTank.Orientation + Vector3.new(math.rad(0), math.rad(0), math.rad(0.05)))
end

function leftyaw()
	BodyGyro.CFrame = CFrame.new(MainTank.Orientation + Vector3.new(math.rad(0), math.rad(0.05), math.rad(0)))
end

function rightyaw()
	BodyGyro.CFrame = CFrame.new(MainTank.Orientation + Vector3.new(math.rad(0), math.rad(-0.05), math.rad(0)))
end

I control the functions with key inputs. In the video, I was pressing WASD, but no result.

And yes, I know the key inputs work fine. I’ve tested them.

And I also changed the vector3 numbers to 15, but still nothing.

Are you looking strictly for a vector3? Usually CFrame.Angles is utilized when rotating CFrame values, for example

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(90),0)

That would rotate the part 90 degrees on the Y axis and it would allow for you to change the existing orientation with ease without the use of Vector3s.

1 Like