How to check accessory type

So I’m trying to make a character customization where you can load HAIR items from the catalog using this:

InsertService:LoadAsset(ID)

And then I was gonna check the Enum.AccessoryType of the Accessory so you can only add HAIRS but no matter, what the accessory type is always ‘Unknown’. Is there anyway to check this?

3 Likes

Can you show the script you use?

but your best bet would be to have a predefined list of hairs or use the roblox API to get a list of hairs from the catalog that the player can choose from. (or, be a sane person and use an already made catalog browser)

1 Like

Local Script:

TextBox.FocusLost:Connect(function(enterPressed)
	if enterPressed then
		remote:FireServer(tonumber(TextBox.Text), character)
	end
end)

Server Script:

remote.OnServerEvent:Connect(function(player, id, character)
	local success, err = pcall(function()
		local new = InsertService:LoadAsset(id)
		local accessory = new:FindFirstChildOfClass("Accessory")
		local handle = accessory:FindFirstChild("Handle")
		local mesh

		game.Debris:AddItem(new, 10)

		for _, v in pairs(accessory:GetDescendants()) do
			if v:IsA("SpecialMesh") then
				mesh = v
			end
		end

		if mesh then
			mesh.TextureId = ""
			accessory.Parent = character
		end
	end)
end)

The script works well but I need a way to only allow hair accessories to be loaded

I want to be able to load your own hairs so players have more options and can make more unique characters

1 Like

use MarketplaceService:GetProductInfo()

using that result, check the AssetTypeId

for ex.

local info = MarketplaceService:GetProductInfo(id)
if info.AssetTypeId == Enum.AssetType.HairAccessory.Value then
-- load
end

You could check if the handle of the accessory has attachment named “HairAttachment”

This should be of help.

you probably dont want to load any asset if you dont know it’s type

Worked like a charm! Thank you

1 Like

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