The BodyGyro object applies a torque (rotational force) on a BasePart such that it maintains a constant angular displacement, or orientation. This allows for the creation of parts that point in a certain direction, as if a real gyroscope were acting upon it. Essentially, it's the rotational counterpart to a BodyPosition.
If you would like to maintain a constant angular velocity, use a BodyAngularVelocity instead.
The CFrame property controls the goal orientation. Only the angular components of the CFrame are used; position will make no difference. MaxTorque limits the amount of angular force that may be applied, P controls the power used in achieving the goal orientation, and D controls dampening behavior.
1local part1 = workspace.Part1 -- The part that will turn to face Part22local part2 = workspace.Part234part1.BodyGyro.CFrame = CFrame.new(part1.Position, part2.Position)
The CFrame property (not to be confused with BasePart.CFrame) determines the target orientation towards which torque will be exerted. Since BodyGyro does not apply translational force, the translational/positional component of the CFrame, CFrame.p, is ignored. Consider using one of the following CFrame constructors in setting this property: CFrame.fromAxisAngle(), CFrame.fromEulerAnglesXYZ() or CFrame.fromEulerAnglesYXZ(). Beware of gimbal lock as you choose which of these methods and what angles (in radians). Additionally, you could use CFrame.new(gyro.Parent.Position, targetPosition) in order to have the BodyGyro "look at" a targetPosition (Vector3).
The D property is how much dampening will be applied to the torque used to reach the goal CFrame. When the part approaches the goal orientation it needs to decelerate, otherwise it will rotate past the goal and have to stop and re-accelerate back toward the goal. This is often creates undesirable rubber-banding effect, so applying dampening using this property is how that effect is avoided. The higher this value is set, the greater the dampening curve becomes, or the slower the part will approach the goal orientation.