Accessory isn't equipping on the player

I have custom accessories that I am trying to equip on the player. Following the devhub article for AddAccessory, I am still unable to get the accessory to equip. Here’s what I’m doing.

  1. The Accessory has an Attachment.

  2. The Attachment objects in the Accessory objects all match the names of Attachment objects in the default character (for the record, I am using R6 but I don’t think this matters).

  3. I tried anchoring the parts in the Accessory but that only teleported my character to the default position of the parts before immediately disappearing.

  4. I even tried doing a sequence that goes along the lines of this, and it does not hang!

     repeat
         humanoid:AddAccessory(accessory)
         wait()
     until accessory.Parent == humanoid.Parent
    

Instead of the intended behavior of equipping to the player and the accessory remaining with the character as its parent, it just deletes immediately irrespective of if I leave it anchored or not.

Is there anything I’m missing? It’s weird because it’s not my first time using AddAccessory as I’ve gotten it to work before on a different project.

Update: After trying to manually copy and paste the attachments into my character, it immediately deletes itself so it’s definitely not a problem with AddAttachment itself. Archivable is set as true.

2 Likes

I Have To Tell You That You Shouldn’t Anchor the parts!

1 Like

And Something Else too, you want to give the accessory to the player when it joins the game?

I tried both anchoring and unanchoring. Neither works. Sorry – should have made that clear; I’m aware that it’s not supposed to be anchored.

And Something Else too, you want to give the accessory to the player when it joins the game?

No, but in a special inventory page that I’m in the middle of creating. It’s also worth mentioning that I send a request from the client to equip the accessories, so the server calls AddAccessory.

What did you name the attachment? The attachment has to have the exact same name as the attachment you want it to attach to

The ones I’m testing right now are named HatAttachment.
My understanding though is that if the attachment is not found then it still parents it inside the character but just doesn’t attach. However, this is not the case and it is immediately deleted.

Could you show us your code?
30 characters

I made an update to the original post, but I found out that manually copying and pasting into the character doesn’t work either. Thus, I don’t think the problem is in my code but I can share it anyways:

for _, accessory in pairs(Items[itemType][itemName]:GetChildren()) do
            -- These are legitimate accessories; I printed to test this theory
	if accessory:IsA("Accessory") then
		local newAccessory = accessory:clone()
		repeat
			humanoid:AddAccessory(newAccessory)
			wait() -- overkill but used when calling AddAccessory once didn't work; still doesn't work
		until newAccessory.Parent == character
	end
end

Are you sure it is running the function? Maybe add a couple of prints to make sure everything is running

Yes, it is running. I mentioned that I printed to test and it did indeed run.

Is the part under the accessory named Handle?

2 Likes

I have this problem rn, it worked fine before but now it just doesn’t work anymore.

1 Like