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?
01 | while true do |
02 | wait( 0.1 ) |
03 | local w = game.Workspace:GetChildren() |
04 | for i = 1 , #w do |
05 | c = w [ i ] :GetChildren() |
06 | for i = 1 , #c do |
07 | if (c [ i ] .className = = "Hat" ) then |
08 | c [ i ] :remove() |
09 | end |
10 | end |
11 | end |
12 | end |
01 | --ClassNames or Names |
02 | local banned = { |
03 |
04 | Hat = true , |
05 | Accoutrement = true , |
06 | Accessory = true ; |
07 |
08 | } |
09 |
10 |
11 | function delete(obj) |
12 | if banned [ obj.ClassName ] or banned [ obj.Name ] then |
13 | game.Debris:AddItem(obj, 1 / 30 ) |
14 | print ( "Deleted: " ..obj.Name) |
15 | end |
Though both of them are valid-ish answers. Simplicity calls for an even better one!
01 | -- || Services || -- |
02 | local Players = game:GetService( "Players" ) |
03 | local Debris = game:GetService( "Debris" ) |
04 |
05 | -- || HatRemoval || -- |
06 | Players.PlayerAdded:connect( function (Player) |
07 | Player.CharacterAdded:connect( function (Character) |
08 | for i,v in pairs (Character:GetChildren()) do |
09 | if v:IsA( "Accoutrement" ) then |
10 | Debris:AddItem(v, 1 ) |
11 | end end |
12 | Character.ChildAdded:connect( function (Item) |
13 | if Item:IsA( "Accoutrement" ) then |
14 | Debris(Item, 1 ) |
15 | end |
16 | end ) end ) end ) |
17 |
18 |
19 | -- 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!