Codectionary / Developer documentation / Luau

WeldConstraint

Keep two parts in a fixed relative position as one assembly.

Why use WeldConstraint?

WeldConstraint joins two BaseParts without an articulated joint. It is useful for a rigid prop made from several pieces; an anchored part can make the whole assembly immovable.

Try it in Roblox Studio

Create two touching Parts named Body and Detail in Workspace. Put this Script in ServerScriptService and run it after the parts exist.

Syntax

weld.Part0 = body
weld.Part1 = detail

Examples

WeldConstraint

Weld a decorative piece to a body part.

local body = workspace:WaitForChild("Body")
local detail = workspace:WaitForChild("Detail")
assert(body:IsA("BasePart") and detail:IsA("BasePart"))

local weld = Instance.new("WeldConstraint")
weld.Part0 = body
weld.Part1 = detail
weld.Parent = body
  1. Part0 and Part1 identify the two BaseParts that should move together.
  2. The constraint maintains their relative transform from the time it becomes active.
  3. This is a rigid connection; use a suitable articulated constraint when the parts should rotate or slide relative to one another.

Best practices

  • Place the parts where you want them before enabling the joint.
  • Avoid anchoring every moving part in an assembly.

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