I am trying to remove players hat, or in my case, hair. But it doesnt seems to work. I have a morth type of thing that when you touch a brick (button) it makes my body invisible and sticks random bricks on the body to make an armor or something.
function onTouched(hit)
local d = hit.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Hat") then
d[i]:remove()
end
end
end
script.Parent.Touched:connect(onTouched)
How ever the hair stays on my head and doesn`t gets removed. Any ideas please? Thank you.

9 comments
wait, className?
http://wiki.roblox.com/index.php?title=API:Class_reference
Oh thanks. Yeah I will fix it right now. I didnt know hair wasnt a "hat", I thought everything on your head is a hat.
Just a new comment. It worked. The morth removed my hair. Thank you astrawr. :D
Note that accessories aren't just hats! They are wings, and all those things you can put on your player. If you want to see for yourself, just press play and look in your player model!
You should not be using remove in your code and Hats still exist but most use Accessories.
You can debug that script by checking if the y value of the Accessory is more than the y value of the Character's head. Just something to think about.
Bad what if there is an accessory that is not a hat
Bad what if there is an accessory that is not a hat