Why can't a local script properly attach an accessory to a character?

So basically I’m creating a cutscene which instead of using the player’s model uses a rig which I just paste all the player’s things onto such as clothing, face, body colors etc.

But since this is happening in a localscript it doesn’t actually move the player’s accessories to the rig (Head accessories not being moved to the head etc.).

I tried:

for i,v in pairs(char:GetChildren()) do
	if v:IsA("Clothing") or v:IsA("ShirtGraphic") or v:IsA("BodyColors") or v:IsA("Accessory") then
		local clon = v:Clone()
		clon.Parent = rig
	end
	
	if v:FindFirstChildWhichIsA("Decal") then
		local clon = v.face:Clone()
		rig.Head.face:Destroy()
		clon.Parent = rig
	end
end

But this just didn’t change the position of the accessory to match the position of the rig.

So I tried again:

for i,v in pairs(char:GetChildren()) do
	if v:IsA("Clothing") or v:IsA("ShirtGraphic") or v:IsA("BodyColors") then
		local clon = v:Clone()
		clon.Parent = rig
	end
	
	if v:IsA("Accessory") then
		local clon = v:Clone()
		clon.Parent = workspace
		wait()
		rig.Humanoid:AddAccessory(v)
	end
	
	if v:FindFirstChildWhichIsA("Decal") then
		local clon = v.face:Clone()
		rig.Head.face:Destroy()
		clon.Parent = rig
	end
end

But this script; gives a warning of “AddAcessory failed: Accessory is already being worn by another character.”

Does anyone know a solution?

2 Likes

Hi! You’re calling AddAccessory(v), but v is accessory in character, he’s wearing it.
You need to do AddAccessory(clon)

1 Like

Yes, that gets rid of the warning, but the accessories still aren’t at the position of the rig.

1 Like

you could try using HumanoidDescriptions to replicate the appearance of the player instead of meticulously pasting features

1 Like

I found that AddAccessory() doesn’t work properly on client

And i think that’s the problem, try to move script to the server
Alternatively you can change Part1 property in AccessoryWeld inside accessory to rig’s head

(I don’t know how HumanoidDescription works, so maybe @glowyogurt’s solution will be better)

3 Likes

I have no idea how HumanoidDescriptions work, so could you potentially tell me how to do it?

1 Like

Humanoid:ApplyDescription(HumanoidDescription)
where humanoiddescription is the humanoiddescription of the player

here are some methods to get humanoiddescription on the documentation:

2 Likes

It can only be called by the backend server which is an issue.