I need some help with this

I am trying to make it so that when a GUI is clicked, the accessories will change.

It removes the current accessories, but it doesn’t add the new ones

here is the script

local Avatar = game.Workspace.Character.MainAvatar

script.Parent.MouseButton1Click:Connect(function()
	local descendants = Avatar:GetDescendants()
	for _, descendant in pairs(descendants) do
		if descendant:IsA("Accessory") then
			descendant:Destroy()
		end
	end
	local accessories = script:GetDescendants()
	for _, descendant1 in pairs(accessories) do
		if descendant1:IsA("Accessory") then
			local main = descendant1:Clone()
			main.Parent = Avatar
		end
	end
	
end)

Are your descendants of script actual accessories? If so, you can literally just run <Humanoid>:AddAccessory(Accessory).

there are a ton of accessories and this will be for multiple buttons, so I was just trying to do this to make it faster.

you must do
game.Workspace.Character.Humanoid:AddAccessory(main)

Humanoid | Roblox Creator Documentation

it still doesn’t work. chars…

can you show me your updated code?

local Avatar = game.Workspace.Character.MainAvatar

script.Parent.MouseButton1Click:Connect(function()
	local descendants = Avatar:GetDescendants()
	for _, descendant in pairs(descendants) do
		if descendant:IsA("Accessory") then
			descendant:Destroy()
		end
	end
	local accessories = script:GetDescendants()
	for _, descendant1 in pairs(accessories) do
		if descendant1:IsA("Accessory") then
			local main = descendant1:Clone()
			Avatar.Humanoid:AddAccessory(main)
		end
	end

end)

Does it return any errors?

Also, you can shorten your first loop with <Humanoid>:RemoveAccessories().

It returns no errors. and thanks

Is the accessory properly set up?

I’m not sure, how to know? btw the accessories are put into the character just it doesn’t show on the character

Does it have a handle, for example?

1 has a handle but it doesn’t work, btw I got the accessories by LoadCharacterPro and InsertService