Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.