Is this what you’re looking for?
local WhitelistAttribute = "Whitelisted" -- in case you ever wanna whitelist accessories
local Players = game:GetService("Players")
local function HandleChild(Accessory : Instance)
if Accessory:IsA("Accessory") and Accessory:FindFirstChildWhichIsA("WrapLayer", true) and not Accessory:GetAttribute(WhitelistAttribute) then -- rather lazy way to check but it is what it is
Accessory:Destroy()
warn("Destroying:", Accessory:GetFullName())
end
end
local function initchar(char : Model)
local ChildAdded = char.ChildAdded:Connect(HandleChild)
char.Destroying:Once(function()
ChildAdded:Disconnect()
end)
char:GetPropertyChangedSignal("Parent"):Once(function()
if not char.Parent then
task.delay(5, char.Destroy, char) -- Roblox doesnt automatically destroy the character on removing so I'm just going to delay it by 5 so it wont break any other scripts
end
end)
for i,v in char:GetChildren() do
HandleChild(v)
end
end
local function initplr(plr : Player)
plr.CharacterAdded:Connect(initchar)
end
Players.PlayerAdded:Connect(initplr)
Players.PlayerRemoving:Connect(function(plr : Player)
task.delay(5, plr.Destroy, plr) -- same reason above but in this case for Players
end)
for i,v in Players:GetPlayers() do
initplr(v)
if v.Character then
initchar(v.Character)
end
end