I scripted this team hat script a while back, and it used to work fine. Now when I enter the game, my character barely even hits spawn, and gets killed. Any ideas?

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 
            if v:IsA("Accessory") then
                v:Remove()

            end
        end
        if Plr.TeamColor == BrickColor.new("Bright red") then -- Check the team Color
            local Hat1 = game.ServerStorage.Hat1:Clone()
            Hat1.Parent = Char
        elseif Plr.TeamColor == BrickColor.new("Bright blue") then
            local Hat2 = game.ServerStorage.Hat2:Clone()
            Hat2.Parent = Char
        end
    end)
end)

5 comments

0

Either this script isn't the problem and you have another that is or the hats you're cloning into the player are causing the problem.

0

It is this script, I tested it out. I don't know how the hats should be the problem......

0

Maybe should I try making the cloned hats accessories?

0

I tried the script, works fine with an Accessory and a Handle in it.

0

Yeah, that's the issue. If I have parts besides the handle in the accessory it doesn't work