Full R6 Transparency Problem

I made a script where if it runs, you supposed to go invisible. It works in R15 but it doesn’t work in R6. I mean I already make it works for the body parts but somehow the Accessory still doesn’t go invisible + the output says that Transparency is not a valid member of Humanoid even if I already made an exception for Humanoid.

script.Parent.OnServerEvent:Connect(function(plr)
	for i, v in pairs(plr.Character:GetChildren())do
		if v:IsA("BasePart") and v.Name ~= "Head" or "Humanoid" then
			v.Transparency = 0
		elseif v:IsA("Part") and v.Name == "Head" then
			v.Transparency = 0
			v.face.Transparency = 0
		elseif v:IsA("Accessory") or v:IsA("Hat") then
			if v:FindFirstChild("Handle") then
				v:FindFirstChild("Handle").Transparency = 1
			end
		end
	end
end)

^^
Script above only make your body transparent and not the accessory as well in R6.

That’s not how you use the or operator, and you should use :GetDescendants() for this.

script.Parent.OnServerEvent:Connect(function(plr)
	for i, v in pairs(plr.Character:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Transparency = 1;
			
			if v.Name == "Head" then
				v.face.Transparency = 1;
			end
		end
	end
end)

the output says that Transparency is not a valid member of Humanoid

That’s because this line:
if v:IsA("BasePart") and v.Name ~= "Head" or "Humanoid" then
is evaluating true as “Humanoid” as a conditional is not 0 or nil, so it’s true.

1 Like

GetChildren() would suffice (and be more performant too) if you’re just making the character’s limbs transparent.

0 is still considered truthy in Lua, I assume you meant “false”.

local num = 0

if num then
	print(true)
end
1 Like