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

How would I fix this "remove hats" portion of my script?

Asked by 7 years ago
Edited 7 years ago

So basically, I have this team hat script. The script itself works fine except for one part-- the original hats the player has do not get removed when they select a team, and get a hat.

Here is the portion of the code that should remove a player's existing hats

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        wait(0.5) -- Wait so that the hats load
        local Contents = Char:GetChildren()
        for _, v in pairs(Contents) do -- Remove all existing hats to add new one(s)
            if v:IsA("Hat") then
                v:Destroy()

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Hats have been changed to "Accessory". Use that instead.

-wiki http://wiki.roblox.com/index.php?title=API:Class/Accessory

0
Thanks! completely overlooked that BartyCrouchJunior 57 — 7y
0
No problem. You might want to use "Accoutrement" though, because that inherits both Accessory and Hat as classname (http://wiki.roblox.com/index.php?title=API:Class/Accoutrement) RubenKan 3615 — 7y
Ad

Answer this question