Welding accessories from client not working

I’m creating a kill effect that turns the victim into a clown.

This is my code. I am using the code to add accessories from the client side taken from this post
Note: There are 3 accessories to weld parented to the script

local utility = require(script.Parent.Utility)

local face = "rbxassetid://629934434"
local shirt = "rbxassetid://5827185600"
local pants = "rbxassetid://5345883043"

function weldAttachments(attach1, attach2)
	local weld = Instance.new("Weld")
	weld.Part0 = attach1.Parent
	weld.Part1 = attach2.Parent
	weld.C0 = attach1.CFrame
	weld.C1 = attach2.CFrame
	weld.Parent = attach1.Parent
	return weld
end

local function buildWeld(weldName, parent, part0, part1, c0, c1)
	local weld = Instance.new("Weld")
	weld.Name = weldName
	weld.Part0 = part0
	weld.Part1 = part1
	weld.C0 = c0
	weld.C1 = c1
	weld.Parent = parent
	return weld
end

local function findFirstMatchingAttachment(model, name)
	for _, child in pairs(model:GetChildren()) do
		if child:IsA("Attachment") and child.Name == name then
			return child
		elseif not child:IsA("Accoutrement") and not child:IsA("Tool") then -- Don't look in hats or tools in the character
			local foundAttachment = findFirstMatchingAttachment(child, name)
			if foundAttachment then
				return foundAttachment
			end
		end
	end
end

function addAccoutrement(character, accoutrement)  
	accoutrement.Parent = character
	local handle = accoutrement:FindFirstChild("Handle")
	if handle then
		local accoutrementAttachment = handle:FindFirstChildOfClass("Attachment")
		if accoutrementAttachment then
			local characterAttachment = findFirstMatchingAttachment(character, accoutrementAttachment.Name)
			if characterAttachment then
				weldAttachments(characterAttachment, accoutrementAttachment)
			end
		else
			local head = character:FindFirstChild("Head")
			if head then
				local attachmentCFrame = CFrame.new(0, 0.5, 0)
				local hatCFrame = accoutrement.AttachmentPoint
				buildWeld("HeadWeld", head, head, handle, attachmentCFrame, hatCFrame)
			end
		end
	end
end

return function(character)
	if not utility:getEffectActive(character) then
		utility:setEffectActive(character, true)
		
		utility:anchor(character)
		utility:color(character, Color3.fromRGB(255,255,255))
		
		local shirtObj = Instance.new("Shirt")
		shirtObj.ShirtTemplate = shirt
		local pantsObj = Instance.new("Pants")
		pantsObj.PantsTemplate = pants
		local faceObj = Instance.new("Decal")
		faceObj.Texture = face

		shirtObj.Parent = character
		pantsObj.Parent = character
		faceObj.Parent = character:FindFirstChild("Head")

		for _,v in pairs (script:GetChildren()) do
			addAccoutrement(character, v:Clone())
		end
	end
end

This is the testing script I am using on the client side to run the effect.

c:WaitForChild("Humanoid").Died:Connect(function()
     require(game:GetService("ReplicatedStorage").Effects["Clown Sword"])(c)
end)

The expected result would be the character turning white, losing all their accessories (which utility:color does, and getting a clown face. The accessories aren’t working:
https://gyazo.com/c47f7002d4ff9196455e0ae767d86ba6

Any help is appreciated.

Are you sure that you’re working with a script, not a local script?

If you actually read the thread you would know that the code that CloneTrooper posted was intended as an alternative to AddAccessory for the client side.

I’ve now solved the problem—it was due to the humanoid dying and its joints breaking.
It can be solved by setting Humanoid.BreakJointsOnDeath to false.