function onClicked(playerWhoClicked)
local playerBody = game.Workspace[playerWhoClicked.Name]
local d = playerBody.Parent:GetChildren()
for i=1, #d do
if (d[i].className == "Hat") then
d[i]:remove()
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
So, I wrote this script that should remove all of a player's hats. It doesn't output any errors, but it doesn't remove the hats.

2 comments
Thanks!
Np!