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

Remove all accessories 100% of the time and add multiple hats on players for teams?

Asked by 7 years ago

This script works but I have a problem with it. First of all, I would like an option to add more hats onto the character (maybe about 4-5 more) for each team. Also, I want to know how to remove all accessories for 100% of the times. Sometimes it works and other times, it leaves all the hats and adds the hat from the ServerStorage... Any help? Thanks!

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CharacterAdded:connect(function(Char)
        wait(0.5)
        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 blue") then
            local Hat1 = game.ServerStorage.Hat1:Clone()
            Hat1.Parent = Char
        elseif Plr.TeamColor == BrickColor.new("Bright red") then
            local Hat2 = game.ServerStorage.Hat2:Clone()
            Hat2.Parent = Char
        end
    end)
end)


2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Some of the hats on ROBLOX are still called Hat so you'd want to remove Accessories and Hats. Also don't use the Remove() method. It is deprecated and should not be used for future work. Instead, use the method called Destroy().

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        wait(0.5)
        for i,v in pairs(char:GetChildren()) do
        if v.ClassName == "Accessory" then
            v:Destroy()
        end
    end
    for i,v in pairs(char:GetChildren()) do
            if v.ClassName == "Hat" then
               v:Destroy()
            end
        end
        if plr.TeamColor == BrickColor.new("Bright blue") then
            local Hat1 = game.ServerStorage.Hat1:Clone()
            Hat1.Parent = char
        elseif plr.TeamColor == BrickColor.new("Bright red") then
            local Hat2 = game.ServerStorage.Hat2:Clone()
            Hat2.Parent = char
        end
    end)
end)

If this helped you, please accept my answer!

0
It works, but do you know how to add more hats onto the characters? Aurified 12 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

No!!!!!!!!! Don't listen to them u can go into the properties of starter player and toggle the box at the bottom that says "Load Character Appearance"

0
That removes the appearance completely, including skin color, shirts&pants,faces,packages etc. LordTechet 53 — 7y

Answer this question