I’m trying to get all the accessory names of all items that a humanoid is wearing. The Accessory ID is only available through humanoid descriptions, but I don’t want to write 8 if statements for each type of accessory. How can I get them all in something like a table?
local mytable = {}
for _, acc in character.Humanoid.HumanoidDescription:GetChildren() do
table.insert(mytable, acc)
end
now mytable will be filled with each accessory. If you wish to use the IDs or other properties:
for _, id in mytable do
--id is equal to an accessorydescription instance, so use how you want
end
This helped me, but I also did it a little differently. Thanks anyway!
local function getIds(humDesc:HumanoidDescription)
local ids = {}
for i,v in ipairs(humDesc:GetChildren()) do
if v:IsA("AccessoryDescription") then
table.insert(ids,v.AssetId)
end
task.wait() -- without this it would lag heavily for some reason
end
return ids
end