I've tried to everything to find one working script (because mine didn't work at all). Apparently, they all don't work. Can anyone help me?
while true do wait(0.1) local w = game.Workspace:GetChildren() for i = 1, #w do c = w[i]:GetChildren() for i=1, #c do if (c[i].className == "Hat") then c[i]:remove() end end end end
--ClassNames or Names local banned = { Hat = true, Accoutrement = true, Accessory = true; } function delete(obj) if banned[obj.ClassName] or banned[obj.Name] then game.Debris:AddItem(obj, 1/30) print("Deleted: " ..obj.Name) end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(c) c.DescendantAdded:connect(function(obj) delete(obj) end) end) end)
Though both of them are valid-ish answers. Simplicity calls for an even better one!
-- || Services || -- local Players = game:GetService("Players") local Debris = game:GetService("Debris") -- || HatRemoval || -- Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) for i,v in pairs(Character:GetChildren()) do if v:IsA("Accoutrement") then Debris:AddItem(v, 1) end end Character.ChildAdded:connect(function(Item) if Item:IsA("Accoutrement") then Debris(Item, 1) end end) end) end) -- Note: You don't have to use Debris, I just use it because I like it so it doesn't pause code to :Destroy() something.
So yeah, as you can see, there's many ways to do this, though my way is a way I've used a lot as someone that makes these scripts (sadly) a lot.
Any questions? Be sure to ask any of us!