Need help getting AssetID from HumanoidDescription Property?

  1. What do you want to achieve?
    I would like to only get the AssetID from the HumanoidDescription AccessoryBlob Property; however, with my limited knowledge about scripting, I’m not sure how to go about doing so.

In the HumanoidDescription AccessoryBlob Property, it has the following text:

[{"AssetId":10713780551,"Order":2,"AccessoryType":"Jacket"},
{"AssetId":12542070940,"Order":0,"AccessoryType":"Pants"},
{"AssetId":12808482080,"Order":1,"AccessoryType":"Sweater"}]

So, in short, how can I make it so the script ignores all the other text besides the Asset ID?

  1. What is the issue?
    I’m not exactly sure how to do this since I’m quite new to scripting :sweat_smile:

  2. What solutions have you tried so far?
    I’ve tried writing following script, but it doesn’t work :confused:

local Accessories = {}

... --Other code handling the other accessories are here, but to save space I did not include it!

local AccessoryBlobs = NPC.Humanoid:WaitForChild("HumanoidDescription").AccessoryBlob
	local AccessoryBlobsTable = AccessoryBlobs:split(",")
	for _, AccessoryBlob in ipairs(AccessoryBlobsTable) do
		if AccessoryBlob ~= 0 then
			if tonumber(AccessoryBlob) then
				table.insert(Accessories, AccessoryBlob)
			end
		end
	end

... --Other code handling the other accessories are here, but to save space I did not include it!

local AddedTable = {}

	for _, ID in ipairs(Accessories) do
		if ID ~= 0 then
			if tonumber(ID) then
				if not table.find(AddedTable, ID) then
					table.insert(AddedTable, ID)
					local Template = script.Template

					local NewTemplate = Template:Clone()
					NewTemplate.ProductIDVal.Value = ID
					NewTemplate.AssetIcon.Image = "https://www.roblox.com/asset-thumbnail/image?assetId=" .. ID .. "&width=420&height=420&format=png"

					NewTemplate.Parent = script.Parent.ScrollingFrame
				end
			end
		end
	end
	
end)

Fixed my own issue

local LayeredClothing = require(NPC.Humanoid:WaitForChild("LayeredClothing"))

	-- Gather information from LayeredClothing
	for i, v in pairs(LayeredClothing) do
		for i2, v2 in pairs(v) do
			-- Insert the AssetId directly into the Accessories table
			table.insert(Accessories, v2)
			
			print("Inserted AssetId:", v2)
		end
	end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.