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)
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!
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"