Hello I was trying to make this script to equip accessories and yes they do get equipped but the thing is that it doesn’t delete the accessories already in the player so multiple accessories are in the player. As you can see in the script the for i loop doesn’t delete it but i cannot find an alternative and i even tried findfirstchild and destroy() but destroy comes up as nil. I have no idea what to do and need help.
local events = game.ReplicatedStorage.Events.Customize
events.OnServerEvent:Connect(function(player,name,category)
if category == "Hair" then
local clone = game.ReplicatedStorage.Customization[category][name]:Clone()
for i,v in pairs(player:GetDescendants()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
player.Character.Humanoid:AddAccessory(clone)
end
if category == "Shirts" then
local clone = game.ReplicatedStorage.Customization[category][name]:Clone()
for i,v in pairs(player:GetDescendants()) do
if v:IsA("Shirt") then
v:Destroy()
end
end
clone.Parent = player.Character
end
if category == "Pants" then
local clone = game.ReplicatedStorage.Customization[category][name]:Clone()
for i,v in pairs(player:GetDescendants()) do
if v:IsA("Pants") then
v:Destroy()
end
end
clone.Parent = player.Character
end
if category == "Hats" then
local clone = game.ReplicatedStorage.Customization[category][name]:Clone()
for i,v in pairs(player:GetDescendants()) do
if v:IsA("Hat") then
v:Destroy()
end
end
player.Character.Humanoid:AddAccessory(clone)
end
end)