✓ Accepted answer
As far as I am aware, hats are also just accessories. Is there a way to differentiate between two hats? Do they contain meshes which point to an asset on the Roblox catalog? If they do the easiest way would be to create a table that contains blacklisted IDs and stops them from being removed.
Although I'm not sure if the following would work, but I hope it will help.
local Blacklisted = { 1000001, 1000002, 1000003 }
function IsBlacklisted(Accessory)
for _, v in pairs(Blacklisted) do
if Accessory.Mesh.MeshId == v
return true
else
return false
end
end
end
if d[i].className == "Accessory" and not IsBlackListed(d[i]) then
But I doubt that we are using meshes, so in your case possibly manually add something that prevents it from being deleted, i.e a bool value which, when true, stops d[i] from being destroyed.
2 comments
I know this is unrelated but you can do for i, v in pairs() instead of for i=1, #d do
Thank you for letting me know