Constraint
The base class of physics joints between two parts: weld, hinge, spring and rope.
- Inherits: Instance
- Subclasses: HingeConstraint, RopeConstraint, SpringConstraint, WeldConstraint
- Creatable: No. It’s an abstract base class: create one of its subclasses, and check for it with
instanceoforisA('Constraint'). - Replication: Replicated: clients get a copy, and changes the server makes reach them.
Create a constraint, point part0 and part1 at two parts and parent it anywhere in the
Workspace (inside the model it belongs to keeps things tidy). An anchored part holds still, so a
constraint to an anchored part pins the other part to the world.
Constraints act only on the game server; players see the parts move through replication. A constraint does nothing while either part is missing or outside the Workspace, when both are the same part, or when both are anchored. Destroying a constraint, or moving it out of the Workspace, lets the parts go.
In 2D games everything stays on the X/Y plane: offsets ignore z, and hinges always turn around Z.
Properties
Section titled “Properties”Type: BasePart | null · Default: null · Access: read/write · Replicates: yes
The first part.
Type: BasePart | null · Default: null · Access: read/write · Replicates: yes
The second part.
enabled
Section titled “enabled”Type: boolean · Default: true · Access: read/write · Replicates: yes
Set false to let the parts go (and true to rejoin).
false lets the parts go; true joins them again.
Inherited from Instance: name, archivable, id, className, parent, destroyed
Methods
Section titled “Methods”Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged