Codectionary / Developer documentation / Luau

HingeConstraint motors

Rotate an assembly around a hinge axis using two attachments.

Why use HingeConstraint?

HingeConstraint allows rotation around one axis. Its Motor mode is useful for wheels or spinning mechanisms; the resulting motion still depends on physical mass, torque, and whether parts are anchored.

Try it in Roblox Studio

In Studio, build two BaseParts with aligned Attachments and connect them using a HingeConstraint named WheelHinge. Put this Script in ServerScriptService; the code configures the existing joint rather than constructing its geometry.

Syntax

hinge.ActuatorType = Enum.ActuatorType.Motor

Examples

HingeConstraint motors

Turn an existing hinge into a motor.

local hinge = workspace:WaitForChild("WheelHinge")
assert(hinge:IsA("HingeConstraint"))
hinge.ActuatorType = Enum.ActuatorType.Motor
hinge.AngularVelocity = 2
hinge.MotorMaxTorque = 1000
  1. A hinge requires Attachment0 and Attachment1 positioned and oriented to define its rotation axis.
  2. Motor mode tries to reach AngularVelocity; MotorMaxTorque limits how strongly it can drive the assembly.
  3. If the connected parts are anchored or the torque is insufficient, the wheel may not move as expected.

Best practices

  • Align the two attachments in Studio before tuning motor values.
  • Test movement with realistic mass and collisions.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading