Hello, I was working on a project that includes a script where I remove ALL accessories EXCLUDING HairAttachments but I wanted to add Face and Hat attachments as well and leave out the rest to be destroyed. Here is the script for anyone who is willing to help!
local Players = game:GetService("Players") function PlayerAdded(Player) Player.CharacterAppearanceLoaded:Connect(function(Character) local parts = Character:GetChildren() for i = 1, #parts do local instanceA = parts[i] if (instanceA.ClassName == "Accessory") then if not instanceA.Handle:FindFirstChild("HairAttachment") then parts[i]:Destroy() end end end end) end Players.PlayerAdded:Connect(PlayerAdded)
You can use and not to chain multiple conditions. Also I used modern way of looping, not your for i = 1, 10, dude it's not 2015, it's not 2020, it's 2023!!!!! )=<
local Players = game:GetService("Players") function PlayerAdded(Player) Player.CharacterAppearanceLoaded:Connect(function(Character) for _, instance in Character:GetChildren() do if instance:IsA("Accessory") then if not instance.Handle:FindFirstChild("HairAttachment") and not instance.Handle:FindFirstChild("HatAttachment") and not instance.Handle:FindFirstChild("face? bla") then instance:Destroy() end end end end) end Players.PlayerAdded:Connect(PlayerAdded)