Hi Devforum,
I’m trying to use HumanoidDescription’s GetAccessories function to get an array of all accessories in that HumanoidDescription.
I expect the table to be full of of my own avatar’s accessory IDs, but instead it is empty.
This is my code:
local Players = game:FindService("Players")
for i,v in pairs(Players:GetHumanoidDescriptionFromUserId(85264884):GetAccessories(true)) do
print(v)
end
And there is no output, because the for loop doesn’t do anything when the table is empty.
Any help would be greatly appreciated.
Thank you!
That’s strange - it should hand you an array without an exception. Does it print the Humanoid’s description at all? If not, I presume it may be affected by Roblox’s service disruptions (http://status.roblox.com/).
Alright, I think it’s on behalf of Roblox’s fault that it can’t get accessories as intended - it’s surprising that it returns an empty array. I’ve created an alternative for this that creates a table:
local plrs = game:GetService("Players")
local desc = plrs:GetHumanoidDescriptionFromUserId(121227196)
local accessories = {
["BackAccessory"] = {};
["FaceAccessory"] = {};
["FrontAccessory"] = {};
["HairAccessory"] = {};
["HatAccessory"] = {};
["NeckAccessory"] = {};
["ShouldersAccessory"] = {};
["WaistAccessory"] = {}
}
for accessory, id in pairs(accessories) do
local split = desc[accessory]:split(",")
if not split[2] then accessories[accessory] = desc[accessory] continue end
accessories[accessory] = split
end
print(accessories)