How can I separate the commas in a humanoid description

Hello, so im making this character game for someone. Its a game where you can look at other characters and equip what they have and it uses humanoid descriptions. Everything is going fine but theres this one problem. They want it to display what items the character has in a ui. The one problem is, if the character has multiple items on it separates the asset id’s with commas. Which means my script will error. If someone can please tell me how to separate the commas and the asset id’s then i’ll greatly appreciate. PLEASE HELP

Does it return a table of asset IDs or is it a concatenated string of asset IDs separated by commas? Can you show us your output.

If the latter, then you can use string.split(string, seperator) to do this, ie:

local assetIDs = "123456,65497,3164"
string.split(assetIDs , ",")

That will then give you a table of Asset IDs you can iterate over

3 Likes
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local description = humanoid:WaitForChild("HumanoidDescription")
local hatAccessories = description.HatAccessory
local hatIds = string.split(hatAccessories, ",")
for _, hatId in ipairs(hatIds) do
	print(hatId)
end

Will output each hat accessory ID to the console belonging to the local player’s character.