Removing accessory ID from humanoid description when accessory is removed help

ok so heres a bit of my server script, so when the player removes an accessory from their character (via a gui list of all accessories in their character). the accessory gets removed from the character but not from the humanoid description?

how can i update the description to be updated with what the player is currently wearing?

btw dont mind the 2 functions, those r just to update the list and stuff.

local function getAccessoryList(character)
    local accessories = {}
    for _, accessory in ipairs(character:GetChildren()) do
        if accessory:IsA("Accessory") then
            local accessoryName = accessory.Name
            local accessoryId = accessory:FindFirstChild("AccessoryId") and accessory.AccessoryId.Value or accessoryName
            accessories[accessoryName] = accessoryId
        end
    end
    return accessories
end

local function updatePlayerAccessories(player)
    local character = player.Character
    if character then
        local accessories = getAccessoryList(character)
        for accessoryName, accessoryId in pairs(accessories) do
            updateWearingListEvent:FireClient(player, accessoryName, accessoryId)
        end
    end
end

removeAccessoryEvent.OnServerEvent:Connect(function(player, accessoryId)
    local character = player.Character
    if character then
        for _, accessory in ipairs(character:GetChildren()) do
            if accessory:IsA("Accessory") then
                accessory:Destroy()
                accessoryRemovedEvent:FireClient(player, accessory.Name)
                break
            end
        end
        updatePlayerAccessories(player)
    end
end)
1 Like

as far as I am aware, there is unfortunately no way to physically edit humanoid description as it is getting real time player data of the character’s avatar
maybe someone else can prove me wrong, however…

if I may ask, though, what context is needed for you to edit the humanoid description?
I can maybe provide another workaround

2 Likes

Sorry i saw this late. Im working on a system where its like a savable/editable humanoid description. And like theres a UI that list all the currently wore accessories and theres a remove button to remove it. But when i click it, it removes the accessory instance just not the accessory ID from the humanoid description, this is a problem because when they go to save their outfit/humanoid description, itll save an id thats not even being wore by the player.

1 Like

I was working around and created a function to actually remove the id from its specific place in the humanoid description, its just the problem is getting the accessory ID from the accessory instance.

local function removeAccessoryFromDescription(humanoidDescription, accessoryType, accessoryId)
	local currentIds = humanoidDescription[accessoryType]
	
	if currentIds then
		local ids = {}
		for id in currentIds:gmatch("%d+") do
			if id ~= accessoryId then
				table.insert(ids, id)
			end
		end
		humanoidDescription[accessoryType] = table.concat(ids, ",")
	end
end
1 Like

was reading this other devforum post and from my understanding getting the accessory id from the instance isn’t possible

according to this however, there is another hacky way around it:

using GetCharacterAppearanceAsync(id), you can then compare the texture and meshID of that specific accessory against the one in game, but then again, this might not produce accurate results 100% of the same

sorry that I’m not of much help, but unfortunately i think this might be the only ‘solution’ :confused:

Oh hey! yea i couldnt figure it out so i scratched this. Thanks for the help though!

1 Like