How would I add an offset to my weld?

  1. What do you want to achieve? I want to achieve a script that welds a part to my player’s torso with an offset.

  2. What is the issue? Whenever I try to add a CFrame offset, the weld breaks and falls.

Here is my script, what do I change to add an offset?

	local newHelm = game.ReplicatedStorage.LeatherTorso:Clone()
	newHelm.Parent = workspace
	newHelm.CFrame = playerr.Character.HumanoidRootPart.CFrame
	newHelm.Anchored = false
	local weld = Instance.new("Weld")
	weld.Parent = newHelm
	weld.Part0 = newHelm
	weld.Part1 = playerr.Character.HumanoidRootPart * CFrame.new(0,0,2)
2 Likes

Part0 and Part1 are expected to be parts, and you can’t multiply a CFrame by a part. For offsets, this is what the C0 and C1 properties are for. At most times, you wouldn’t really use the C1, you’ll just use the C0

C0 is the offset for the Part1 relative to Part0’s CFrame, so it’s how far it’ll position and orient from Part0’s CFrame. C1 is just subtracted from C0 to get the offset point. Here’s what your code should have:

local newHelm = game.ReplicatedStorage.LeatherTorso:Clone()
newHelm.Parent = workspace
newHelm.CFrame = playerr.Character.HumanoidRootPart.CFrame
newHelm.Anchored = false

local weld = Instance.new("Weld")
weld.Part0 = newHelm
weld.Part1 = playerr.Character.HumanoidRootPart
weld.C0 = CFrame.new(0, 0, 2)
weld.Parent = newHelm

So, the offset will be 0, 0, 2, meaning that the Part1 will be 2 studs behind the player’s HumanoidRootPart

5 Likes

This worked absolutely perfect! Thank you!

Or, you can use a Weld Constraint, you don’t have to adjust C0 and C1 with this, you can use it’s own CFrame independently