This script doesn't work when It comes to removing ClassName "Accessory", but It works when I tested It on ClassName "Part". How to fix it, and why It happens?
Find = char:GetChildren() for i = 1,#Find do if Find[i].ClassName == "Accessory" then Find[i]:Destroy() end end
Don't use 'for i =' loop if you want to remove hats.
Use this method instead:
for _, v in pairs(char:GetChildren()) do if v:IsA('Accessory') then local accessory = v accessory:Destroy() end end
The reason might be that your script is running before the character's appearance has loaded. To do that you add repeat wait() until Player.HasAppearanceLoaded
Player.HasAppearanceLoaded returns true or false.
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) repeat wait() until Player.HasAppearanceLoaded local Find = Character:GetChildren() for i = 1,#Find do if Find[i].ClassName == "Accessory" then print(Find[i]) Find[i]:Destroy() end end end) end)
You can use the Humanoid:RemoveAccessories() function.
plr.CharacterAdded:Connect(function(char) char:WaitForChild"Humanoid":RemoveAccessories() end)
Or you can use an event called ChildAdded and check if the child is an Accessory
plr.CharacterAdded:Connect(function(char) char.ChildAdded:Connect(function(c) if c.ClassName == "Accessory" then game:GetService"Debris":AddItem(c, 0.1) end end) end)