Parts not welding? (Mass welding)

I am making custom hitboxes, it just dynamically duplicates the body parts.

It does print the right results, but it doesn’t seem to be welded (aka. falling down)

Code (server script):

local character = script.Parent.Parent
local hitboxFolder = script.Parent.Parent.Hitbox or character:WaitForChild("Hitbox")

repeat task.wait() until character:IsA("Model")

for i,v in pairs(character:GetChildren()) do
	if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
		
		print(v.Name, "found: "..v.ClassName)
		
		task.wait()
		
		local hitBox = Instance.new("Part")
		hitBox.Parent = hitboxFolder
		hitBox.Name = v.Name.."_hitBox"
		hitBox.CanCollide = false
		hitBox.Massless = true
		hitBox.Size = v.Size
		hitBox.CFrame = v.CFrame
		hitBox.Material = Enum.Material.Neon
		hitBox.BrickColor = BrickColor.new("Bright red")
		
		print(hitBox.Name, "created: "..hitBox.Name)
		
		task.wait()
		
		local weld = Instance.new("Weld")
		weld.Name = v.Name.."_weld"
		weld.Parent = hitBox
		weld.Part0 = v
		weld.Part1 = hitBox
		
		print(weld.Name, "welded: "..weld.Part0.Name, "-", weld.Part1.Name)
		
	end
end

Explorer:
image

Results (it only does it for the head):


image

ONE LAST NOTE:

theres a script in ServerScriptService that does Humanoid:ReplaceBodyPartR15()

Weld requires a C0 and C1 with setting it. You should use WeldConstraint instead, it works much better:

local weld = Instance.new("WeldConstraint")
weld.Name = v.Name.."_weld"
weld.Parent = hitBox
weld.Part0 = v	
weld.Part1 = hitBox

…Same results :frowning: (its kind of offset)

Are you trying to set it to the head? If you are, do this:

hitBox.CFrame = v.CFrame

I am already doing that. (look in code)

That’s not my priority right now, I just need to weld the hitbox parts.

Nvm, got it to work

Just had to connect both server scripts so when the Humanoid:ReplaceBodyPartR15() is done, I would create the hitbox