Trying to get an instance within and instance using a for loop

I am trying to make a clone a Players Character and make it semi-transparent (like a ghost) once they press the “E” key, the problem is however that the Character clones and the parts and textures become semi-transparent but the accessories of the Character is not. Is there a way to loop through, get the accessories, then loop through each accessory and get its mesh part furthermore changing the transparency of the mesh part and consequently the the accessory?

Sorry for the possible grammatical errors, Its quite late when I am posting this.

Code so far:

local character = game.Players.LocalPlayer.Character or 
   game.Players.LocalPlayer.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")
game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		character.Archivable = true
		local clone = character:Clone()
		clone.Parent = workspace
		
		for i,v in pairs(clone:GetChildren()) do
			if v:IsA("BasePart") then
				v.Transparency = 0.5
				
				if v:IsA("Accessory") then
					for i,b in pairs(v:GetChildren()) do
						if b:IsA("MeshPart") then
							b.Transparency = 0.5
						end
					end
				end
			end
		end	
	end
end)

What I get when I press ‘E’:
image_2022-11-13_191218810

replace with if v:IsA(“BasePart”) then with

if v:IsA("BasePart") or v:IsA("Accessory") then
2 Likes
local clone = character:Clone()
		clone.Parent = workspace
		
		for i,v in ipairs(clone:GetDescendants()) do
			if v:IsA('BasePart') then
				v.Transparency = 0.5
			end
		end
1 Like