I'm trying to delete the player hats when the player spawns. Everything seems fine in the code, but it's not deleting my hats.
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
for _, child in ipairs(character:GetChildren()) do
if child.ClassName == "Accessory" then
child:Destroy()
end
end
end)
end)
*Updated to child:Destoy() but it still does not work

2 comments
On line 5 change child.Destroy() to child:Destroy() with a colon instead of a period.
You can use a period, he just needs to put child between the brackets if you use a period. :Destroy() is syntax sugar for .Destroy(child)