Roblox’s physics system allows you to construct moving mechanisms like doors, rotating platforms, and even vehicles using constraints. For instance, a swinging door can be built using the HingeConstraint.
Start by creating parts for the door and its attachments. Attachments are where one object can connect to another. These attachments will later be used to connect the door to its frame with a hinge.
Create two parts with names like Door and DoorFrame.
Select DoorFrame. In the Properties, enable Anchored so it won’t move.
In the Explorer, hover over DoorFrame and add a new Attachment. Repeat the same to add an attachment to the Door.
Rename the attachments to indicate what they’re attached to, such as DoorAttachment and FrameAttachment.
Move the Attachments
New attachments are created in the center of a part. So they can work with the door, the two attachments need to be moved to face each other.
To view constraints and attachments, in the Model tab, toggle on Constraint Details.
In the Explorer, select FrameAttachment.
Press F to focus on the attachment and zoom in if needed. Then, use the Move tool to position the attachment on the surface of the door frame, facing the door.
It’s best to position attachments so they’re precisely aligned with one another. In this case, misaligned attachments may cause the door to swing incorrectly.
For precise positioning, use Snap to Grid with increments appropriate for the size of the part. Alternatively, edit the attachment’s position in the Properties window.
Repeat the same to move DoorAttachment. Your attachments should be positioned on the surface facing their counterpart.
Rotate the Attachments
The orientation of an attachment affects how a constraint can move. For the door, both attachments must be rotated so the hinge swings left and right, like those on a standard door.
On the door frame, hover over FrameAttachment. Notice the yellow arrow. This arrow, the axis, determines the hinge’s rotation.
Starting Orientations May Differ
Depending on the DoorFrame object, the axis may point in a different direction. For instance, a hinge added to the attachment shown above would pivot around the yellow arrow, like in the video below.
For accurate rotation, turn on snapping in Model → Snap to Grid, and checking Rotate. Set the value to
Use the Rotate tool to orient both yellow attachments to point upwards. If your axes are already vertical, no action is needed.
Next Page Creating the Hinge