How to track the orientation of a part?

So I am trying to make a fully controllable rocket in Roblox and I want to make a gimbal system for the engines to keep the rocket upright. However for this I need to track the rockets orientation so I added a part to the rocket and named it the gyroscope. My question today is, is there any good method of tracking the orientation/rotation of the part? I have tried checking the orientation value of the part but that doesn’t get updated when the rocket is flying. The only way I can think of is using CFrames but I’m not very experienced with those, so can anyone help me or give me a efficient way of checking if the rocket is tilting in a certain axis?

U sure it doesn’t get updated?

Yeah, it’s a cylinder and the orientation remains 0,0,90 throughout the whole thing

Well that’s weird. Can I check the script that u used?

Why not use a BodyGyro or AlignOrientation instead?

1 Like

I checked it in the explorer, I also used the .changed function on the part itself and wasn’t printing anything

I want to make it as realistic as possible and for bodygyro I will need to track the position of the part to know how to rotate the rocket

The properties panel doesn’t update the properties caused by physics in realtime. Same with .Changed or :GetPropertyChangedSignal()

U must use Heartbeat or Stepped

So I should just put it in a while wait() do loop and have it print the orientation?

I said to use Heartbeat or Stepped since they run every frame

Have you considered CFrame.Angles?

CFrame.new(CFrame.Angles(88,88,88)) --> [0,0,0,88,88,88, *rotation matrix follows*]

Ok I will try it
30 characters

I don’t want to make a new CFrame, I want the track the orientation/rotation of a part

If the orientation isn’t changing, that means there’s an issue with the underlying script. What are you doing with the part in the first place

You don’t need to. Angles is a property of all CFrames that points to the Angles of each CFrame.

I used CFrame.new so that you could just paste my example into the command bar and see the result.

I have some cylinders as engines and they are welded to the main rocket, then I apply a body thrust force to each of them

So print(part.CFrame.Angles)?
30 characters

Yes. Keep in mind this returns a LookVector which points to the forward vector of the part, not the upward vector. Trying to use Angles on a part immediately after creation should result in a CFrame reading [0,0,0,90,0,90...]

If you want the upVector you will need to deal with some rotation matrix processing.

You also can’t directly write Angles because it’s only a property of CFrame – you would want to multiply CFrame.Angles with a blank CFrame.new if you want a writable value, or hack it into a Vector3 with this headache inducing lua:

Vector3.new(part.Cframe.Angles.X,part.Cframe.Angles.Y,part.Cframe.Angles.Z) -- results in a Vector3 angle which can be directly written to a part's orientation value

(Though if you’re using Cylinder parts that won’t matter because you have to turn the lookVector upwards in order to stand a cylinder vertically.)

You mentioned using heartbeat and stepped, will they both work on a server script? I have used the runservice before a bit and I don’t believe it works on server scripts

They do. Only RenderStepped doesn’t work. Also, control scripts should be done in the client with the rocket’s network ownership set to the controlling player for instant feedback