My hats aren't transparent in first person view

Hello, right now, I am having trouble with making my hats transparent in first person view. When I first saw this issue, I tried doing if child:IsA(“BasePart”) or child:IsA(“MeshPart”) and child.Name ~= “Head” then but that didn’t work. I did “MeshPart” because the hats on my characters are all MeshParts. Since this didn’t work, I renamed most of the hats either glasses, hats, or hair and basically did the same but it said LocalTransparencyModifier couldn’t be found? So my question is, is there a way for me to make the hats transparent or do I have to make them inside of an accessory?

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local camera = workspace.CurrentCamera

-- Camera Settings

player.CameraMaxZoomDistance = 0.5
camera.FieldOfView =  100
humanoid.CameraOffset = Vector3.new(0,0,-1)

-- Changing Transparency

for childIndex, child in pairs(character:GetChildren()) do
	if child:IsA("BasePart") and child.Name ~= "Head" then
		
		child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			child.LocalTransparencyModifier = child.Transparency
		end)
		
		child.LocalTransparencyModifier = child.Transparency
	end
end

My guess is that this is happening because you’re indexing the character before the hats are added. So to solve this, I’d create a .ChildAdded connection inside of the character.

1 Like

When you say inside the character, do I put it after the ‘for’ statement or before it?

I don’t think it really matters. I’d probably do it after though in case some edge case happens where a part slips through and the property changed connection is made twice.

1 Like

uhh
bro
put the hat inside of the character and it will automatically do it

don’t you think I already did that…