Welding parts and models to players by OffsetCFrame

All I wanted was to weld a model and two parts to a Character, and now… I’ve wasted 13 hours.
What the script is supposed to do is self-explanatory. It all works except the positioning. I tried not using C0 and just changing the CFrame to the right position, but no matter what, it positions the model/parts in the center of their relative part. Now with C0, they aren’t even near the player. There are no errors with getting the right Name or anything so don’t respond if you are just gonna say that, please.

		local model = game:GetService("ServerStorage"):WaitForChild("Belt"):Clone()
		model.Parent = workspace
		--belt
		local c1 = (workspace.StarterCharacterREF.LowerTorso.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.Model.WeldLowerTors.CFrame))
		local weld = Instance.new("Weld")
		weld.Part1 = character.LowerTorso
		weld.Part0 = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")
		weld.C0 = character.LowerTorso.CFrame * c1
		weld.Parent = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")

		--leg
		local c2 = (workspace.StarterCharacterREF.LeftUpperLeg.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.KnifeHold.CFrame))
		local weld2 = Instance.new("Weld")
		weld2.Part1 = character.LeftUpperLeg
		weld2.Part0 = model:WaitForChild("KnifeHold")
		weld2.C0 = character.LeftUpperLeg.CFrame * c2
		weld2.Parent = model:WaitForChild("KnifeHold")

		
		--shirt
		local c3 = (workspace.StarterCharacterREF.UpperTorso.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.ShirtPart.CFrame))
		local weld3 = Instance.new("Weld")
		weld3.Part1 = character.UpperTorso
		weld3.Part0 = model:WaitForChild("ShirtPart")
		weld3.C0 = character.UpperTorso.CFrame * c3
		weld3.Parent = model:WaitForChild("ShirtPart")
4 Likes

Weld offsets are already relative. When you multiply your C0 offset by the character part’s cframe, it’ll go crazy. For example, replace:

with just c2 and see what happens.

Steps to weld:

  1. Set your Part0 to the character part you’re welding to.
  2. Set your Part1 to the part you’re welding onto the character.
  3. Set your C1 (or C0, C1 is better here) to the offset you want. Try CFrame.new(0, -2, 0) for a start.
  4. Parent your weld somewhere in the workspace. I suggest it’s Part0.

Regarding step three and setting your C1:
CFrame the model you’re welding to the character’s root part, then set your C1 to JUST the offset you’re calculating with :ToObjectSpace().

3 Likes

Thanks for the extra advice, but its nothing new. I want exact coordinates. Not trying a new cframe if the other one was a bit too much, or a bit too little. I already have a model in workspace to position these parts on the player.

Edited the post with some more information to better suit your situation.

Now everything is offset the wrong way, I would like to just throw in a negative but I don’t know anything now.

local c1 = (workspace.StarterCharacterREF.LowerTorso.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.Model.WeldLowerTors.CFrame))
		local weld = Instance.new("Weld")
		weld.Part1 = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")
		weld.Part0 = character.LowerTorso
		weld.C1 = c1
		weld.Parent = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")

Please provide relevant code lines and if you haven’t, follow the weld steps and change your Part0 and Part1 correctly. If you’re using C0, try using C1.

1 Like

Completed, the code has been added.

-- CFrame model to character so they align how you'd like, then weld:
    local weld = Instance.new("Weld")
    weld.Part0 = character.LowerTorso
    weld.Part1 = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")
    weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame) -- change this to C1 if it doesn't work correctly
    weld.Parent = weld.Part0
1 Like

So do the c1 thing then weld with the script you provided

		local c1 = (workspace.StarterCharacterREF.LowerTorso.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.Model.WeldLowerTors.CFrame))
		model:WaitForChild("Model"):SetPrimaryPartCFrame(character.LowerTorso.CFrame * c1)
		local weld = Instance.new("Weld")
   		weld.Part0 = character.LowerTorso
    	weld.Part1 = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")
    	weld.C1 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame) -- change this to C1 if it doesn't work correctly
    	weld.Parent = weld.Part0

I’m very thankful that you are helping me, but now its like this. And flipped across the torso for C0.

Seems like an issue with your original CFraming of your model. Not sure what your model looks like, but make sure it is lined up with your character how you’d like it. Something like:

model:SetPrimaryPartCFrame(character:GetPrimaryPartCFrame())

assuming your model’s primary part is also a HumanoidRootPart and the model is set up to the same scale as the character.

The models were exact, same humanoid desc, everything. I am decided on going for the one where it is offset the wrong way, and just * by cframe, it will defeat the purpose and be a waste of time, but… i…huuuh, dont know.

This is what you should use accessories for. They will help you do all this work on the backend and then you won’t have to do all that much from your own end.

Instead of a model, use an accessory and make sure it includes a part named Handle (preferably the part that all the model parts are welded to as well as the one attached to the character). Add an accessory that matches one from a character into your handle (e.g. LowerTorso’s WaistRigAttachment). Then, just place the accessory in the character and you’re good to go.

3 Likes

@Eqicness Has helped me alot on the way here, but after using most of his teachings, and some of my trial/error, I was able to come up with a great solution. Turns out inversing c1 (do not mistake for C1) works.

		local c1 = (workspace.StarterCharacterREF.LowerTorso.CFrame:ToObjectSpace(workspace.StarterCharacterREF.Belt.Model.WeldLowerTors.CFrame))
		local weld = Instance.new("Weld")
   		weld.Part0 = character.LowerTorso
    	weld.Part1 = model:WaitForChild("Model"):WaitForChild("WeldLowerTors")
--    	weld.C1 = c1          (offsets the wrong way)
		weld.C1 = c1:Inverse() -- offsets the right way
    	weld.Parent = weld.Part0

The “StarterCharacterREF” is a player model we have in workspace where we can place parts on to design the characters appearance.

4 Likes