Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesnt my weld set properly?

I am creating an equip script for a sword. My sword doesn't set its Coordinate Frame appropriately. I don't know if this is a problem with the weld or the :PivotTo() function.

Here is what I have going on:

	local PlayerArm = character:FindFirstChild("Right Arm")
	
	local newSword = weapons.Sword:Clone()
	newSword.Name = "Sword"
	newSword.Parent = PlayerArm
	
	local Handle = newSword.PrimaryPart
	
	local newWeld = Instance.new("WeldConstraint")
	
	newWeld.Name = "HandConnecter"
	newWeld.Part0 = PlayerArm
	newWeld.Part1 = Handle
	newWeld.Parent = PlayerArm
	
	local adjustedCFrame = PlayerArm.CFrame * CFrame.new(0,-1,0) --Lower the sword
	
	newSword:PivotTo(adjustedCFrame * CFrame.Angles(0,math.rad(90),math.rad(90)))

1 answer

✓ Accepted answer

My guess is that you have to create the weld after using PivotTo:(). Additionally try setting Part0 to Handle and Part1 to PlayerArm.

This discussion is preserved as it was. New answers, comments, and votes are closed.