Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remove default hat(s) on join?

Asked by 8 years ago
Edited 8 years ago

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?

01while true do
02wait(0.1)
03local w = game.Workspace:GetChildren()
04for i = 1, #w do
05c = w[i]:GetChildren()
06for i=1, #c do
07if (c[i].className == "Hat") then
08c[i]:remove()
09end
10end
11end
12end
1
Scripting Helpers is not a request site; please edit your post to include your code. Pyrondon 2089 — 8y
0
The ClassName is "Accessory" User#13357 0 — 8y

3 answers

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
8 years ago
01--ClassNames or Names
02local banned = {
03 
04    Hat = true,
05    Accoutrement = true,
06    Accessory = true;
07 
08}
09 
10 
11function 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
View all 24 lines...
Ad
Log in to vote
0
Answered by
Zeoic 40
8 years ago

They are no longer considered "Hat" they are now "Accessory".

Log in to vote
0
Answered by 8 years ago

Though both of them are valid-ish answers. Simplicity calls for an even better one!

01-- || Services || --
02local Players = game:GetService("Players")
03local Debris = game:GetService("Debris")
04 
05-- || HatRemoval || --
06Players.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
16end) 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!

Answer this question