Welds from Accessories and Tools do not stack on R6 rigs

Reproduction Steps
Repro: Attach multiple hats to any R6 character via a script. Repro file below
HatBugRepro.rbxl (42.0 KB)

Expected Behavior
All hats should stay on the character.

Actual Behavior
It seems that there cannot be more than one weld with the same name on the same part, which hats and tools use. This issue only applies to R6 characters.

In the gif below, a different hat is added to each rig every second. As you can see, the R15 and Rthro rigs attach the hats correctly, while with the R6 rig, previous hats will fall off.

hatbug

Workaround
The only workaround I could find was to manually weld hats myself using a function I found from a module. Here it is for anyone who needs it:

local function addAccessory(character, accessory)
	local attachment = accessory.Handle:FindFirstChildOfClass("Attachment") -- Not all Accessories are guaranteed to have an Attachment - if not, we'll use default hat placement.
	local weld = Instance.new("Weld")
	weld.Name = "AccessoryWeld"
	weld.Part0 = accessory.Handle
	if attachment then
		-- The found attachment name in the accessory matches an existing attachment in the character rig, which we'll make the weld connect to.
		local other = character:FindFirstChild(tostring(attachment), true)
		weld.C0 = attachment.CFrame
		weld.C1 = other.CFrame
		weld.Part1 = other.Parent
	else
		-- No attachment found. The placement is defined using the legacy hat placement.
		weld.C1 = CFrame.new(0, -.1+character.Head.Size.Y / 2, 0) * accessory.AttachmentPoint:inverse()
		weld.Part1 = character.Head
	end
	-- Updates the accessory to be positioned accordingly to the weld we just created.
	accessory.Handle.CFrame = weld.Part1.CFrame * weld.C1 * weld.C0:inverse()
	accessory.Parent = character
	weld.Parent = accessory.Handle
end

Issue Area: Engine
Issue Type: Other
Impact: Moderate
Frequency: Often
Date First Experienced: Today, 2021-06-30

5 Likes

If this is the same issue as the other thread, I think it may be resolved:

3 Likes

Thank you for this thread. This was exactly the issue my game was having earlier today and it appears to be fixed now. My issue was with tools (rather than hats), but same issue.

@Lightning_Splash can u please confirm that the issue is fixed?

Yes, the issue is fixed. I marked the other reply as a solution

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.