Help on rotating

Hello I have no idea how to use rotating so thats why im here. I am trying to make an aimpoint flip up when the person takes out the gun but i want it to be smooth. Here is what I am dealing with. Note that all I want is the aimpoint to flip up


Before picture After picture Notice that I have 2 blocks that need to be moved (the other one is just a union)

1 Like

If you want to do any sort of smooth transition you can use Tweens/Lerp to do so. Tweens are used for properties while you usually use lerps for CFrame.
^ Tween API ref

To actually do the rotating for lerping you would lerp with CFrame.Angles to change the rotation while for tweens all you would need to do is tween the orientation.

Or try welding the moving Parts/Unions of the sight together with a WeldConstraint, then using a HingeConstraint set to Servo attached to the gun as well as the sight. You can then script the HingeConstraint to move from one angle to another by whatever speed you want.

oke umm i have no idea how to do any of those things

Look up a YouTube video or use the API ref links we sent, tweens are super super easy and lerps are pretty easy too.

Basically a HingeConstraint is set up to act on Attachments that are attached to the two parts you want to move in relation to each other. One on the base you are using (in this case the gun) and the other is on the sight.
In Studio you can go into the Model tab, then click on the Create tab (two small green boxes joined by a green line). I also check the 3 boxes next to that (show welds, constraint details and show on top) to display the constraint visually. When you click on Create a drop down menu appears so select Hinge and then go into your Studio window to click on the part you want as the base, then the part you’d like to move. The Attachments will automatically be formed when you do this, but they won’t be in the right place and probably won’t be at the correct angles. Move the one in the Base to where you want the hinge point to pivot, then move the one in the sight to match up with the first Attachment. Make sure the orange and yellow arrows in the Attachments are pointing the same directions.
In the HingeConstraint’s Properties you can select the ActuatorType and change it to Servo. This means it will move to whatever angle you tell it to. Now Check the LimitsEnabled box and use the LowerAngle, Restitution and UpperAngle vaues to determine the limits of where your sight moves. Depending on how you built it these are probably 0 degrees and 90 degrees. It will be easier to set the Restitution to 0 degrees by rotating the base Attachment until it sits at 0 and your ‘extended’ position is at 90 degrees (or -90, depending on how it’s set up).
In the script that un-holsters the gun have a section that refers to the name of the Part that contains the HingeConstraint and change the HingeConstraint.TargetAngle to 90 (or -90) and have an AngularSpeed about 0.5 (you can mess with this to get the speed you want). When you holster the gun do the reverse, set the TargetAngle to 0.
That’s all you have to do to get a hinge to move back and forth.
Working on a quick door to show you how it can be done.