I want when I touch this part, all hats in my character get removed.
Part = script.Parent Part.Touched:connect(function(hit) for i,v in pairs(hit.Parent:GetChildren()) do v.Transparency = 1 if v:IsA("Hat") then v:remove() end end end)
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) -- Verify the thing that touched the part is actually a player 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)