How can i make my avatar invisible

I am trying to make my avatar invisible but whenever i do the hats stay visible, how can i fix it.

		for _, descendant in pairs(char:GetDescendants()) do
			if descendant:IsA("BasePart") or descendant:IsA("Decal") then 
					            descendant.Transparency = 1
					        end
				    end
for _,i in pairs(char:GetDescendants()) do
    if string.match(i.ClassName, "Part") then -- Checks if the Item has "Part" inside of its Class
        i.Transparency = 1
    end

end

I tried the code and it still doesnt work for me?

try printing the items by doing print(i), are you sure this is a LocalScript?

I never said it was a local script im doing this in a server script

Why are you doing it inside a Server Script?
Are you trying to make everyone invisible or just you?

I am trying to make myself invisible on the server also the code only prints out body parts

Put this inside StarterCharacterScripts

local Character = script.Parent


for _,i in pairs(Character:GetDescendants()) do
	if string.match(i.ClassName, "Part") or i:isA("Decal") then
		print(i)
		i.Transparency = 1
	end
end

if you see Handle in the output, should be working

Nope doesnt work its still the same.

Works for me (Set to .9 to be visible)


Are you sure you are putting this correctly?

I checked and it also works for me but only if i change my avatar to r15 which my game uses r6

Should still work, it gets all the Items that has “Part” inside its Class

Instead, check if it’s a BasePart

Its better to check if its a Part, string.match is looking for all objects that have Part in it’s class

Well check for yourself if you switch the setting to r6 it stops working

No, most properties of a part are inherited from BasePart, you should use BasePart over a string match.

This is the best answer, also checks for decals that I forgot about.

I tested both, they both work the exact same

That still doesnt make the accesories invisible on r6 tho :confused:

Give me a second, I’m gonna check it.