First of all, the remove method is deprecated, you should be using destroy instead. Now, as to why this isn't working, you're attempting to set the Transparency property of all children of the character. Not all children of the character have a Transparency property, so you'll get an error when trying to set the property on a child that doesn't have it.
Here's a more robust version, tested and it's working:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
for i, v in pairs(hit.Parent:GetChildren()) do
if v:IsA("Hat") then
v:Destroy();
end
end
end
end)
2 comments
Whats about the transparency?
@PreyStar what exactly are you trying to do? Remove the hats and set the player's parts to transparent?