How do you call the accessories of a player and destroy all of them but the hair?

local plrs = game:GetService(“Players”)
local starterCharacter = workspace.StarterCharacter

plrs.PlayerAdded:Connect(function(player:Player)
player.CharacterAdded:Connect(function(character:Model)
local userID = player.UserId
local hum = character:WaitForChild(“Humanoid”)
local includeRigidAccessories = true
local shum = starterCharacter:WaitForChild(“Humanoid”)
for _ , v in pairs(plrs:GetHumanoidDescriptionFromUserIdAsync(userID):GetChildren()) do
if v:IsA(“Accessory”) then
v:Clone()
elseif v:Clone() then
shum:ApplyDescriptionAsync(plrs:GetHumanoidDescriptionFromUserIdAsync(userID))
player.Character = starterCharacter
end
end

	for _ , accessory in pairs(character:GetChildren()) do
		if accessory:IsA("Accessory") then
			print(accessory)
		end
	end
end)

end)

–the code that im showing is the code that i have to print the names of the accessories but i just dont know how to destroy all of them but the hair–

1 Like

accessory class has a property called AccessoryType
https://create.roblox.com/docs/reference/engine/classes/Accessory#AccessoryType

you can filter it using Enum.AccessoryType

for _ , accessory in pairs(character:GetChildren()) do
		if accessory:IsA("Accessory") and accessory.AccessoryType ~= Enum.AccessoryType.Hair then
			accessory:Destroy()
		end
	end
1 Like

Tysm bro i’ve been trying to figure out this issue for almost a month or 2 now, this is mostly because i don’t have the tilde key on my keyboard

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