I Don/t know why it not removing it, It should work
function onChildAdded(child) if child.className == "Accessory" then child.Parent = nil child:ClearAllChildren() child:Destroy() end end game.Workspace.ChildAdded:connect(onChildAdded) wait(300) local lastcheck = false while true do wait(60) local pls = game.Players:GetChildren() if #pls == 0 then if lastcheck then Instance.new("ManualSurfaceJointInstance") end lastcheck = true else lastcheck = false end end
I get mixed messages out of this.
-- || Services || local Workspace = game:GetService("Workspace") local Players = game:GetService("Players") -- || ChildAdded Destroy || Workspace.ChildAdded:connect(function(Item) if Item:IsA("Accoutrement") then --This'll remove Hats, Accessories and Accoutrements. Item:Destroy() end) -- || Character Accessory Removal || Players.PlayerAdded:connect(function(Ply) Ply.CharacterAdded:connect(function(Char) for i,v in pairs(Char:GetChildren()) do if v:IsA("Accoutrement") then v:Destroy() end end) end)
Logically, as Cabbler mentioned, the loop you gave was unnecessary since there's a lot of functions that could trigger at the time you're probably wanting.
It should work if you wait(). This only deletes accessories that players want to remove, I hope you know that.
function onChildAdded(child) if child:IsA("Accessory") then --this is safer --wait so that you do not interrupt the child addition wait() --you only need one function child:Destroy() end end workspace.ChildAdded:connect(onChildAdded)
The loop other loop seems really irrelevant and useless.