Can't figure out how to sift through a table

  1. What do you want to achieve? An ability that renders the player invisible, then makes them visible (keeping the parts that were invisible before invisible)

  2. What is the issue? I added all the names of the invisible parts into a table, and when i go to tween the to be visible the only thing that becomes visible is the humanoidrootpart.

  3. What solutions have you tried so far? I’ve tried looking up tables and reading up on them but nothing has helped so far.

here’s the code

for i, v in pairs(Character:GetDescendants()) do
	if v:IsA("MeshPart") or v:IsA("BasePart") then
		for i, part in pairs(transparentParts) do
			if v.Name ~= part then
				TweenService:Create(v, TweenInfo.new(0.7, Enum.EasingStyle.Sine), {Transparency = 0}):Play()
			end
		end
	end


	if v:IsA("BillboardGui") then
		v.Enabled = true
	end
	
	table.clear(transparentParts)
	end

you don’t need to have a loop inside a loop like this using the same variable i this will go through all transparentparts every time it checks a part on the above loop

so how should I go about this if im not looping twice?

I think you could use attribute to do this easily with no tables…
so what you do is before you change the transparency on a part use something like this:

Part:SetAttribute('OriginalTransparency', Part.Transparency) – set the parts transparency in an attribute to check later when you want to change it back to original

below is part of your code using that above attribute to change it back to original

for i, v in pairs(Character:GetDescendants()) do
	spawn(function()   -- I use spawn here so it can instantly go through all the descendants
		if v:IsA("MeshPart") or v:IsA("BasePart") then  -- don't need this if checking where you are setting the OriginalTransparency attribute at
			local OriginalTransparency = v:GetAttribute('OriginalTransparency')  -- see if transparency was set before
			if OriginalTransparency then
				TweenService:Create(v, TweenInfo.new(0.7, Enum.EasingStyle.Sine), {Transparency = OriginalTransparency}):Play()  -- set it back to original Transparency
				v:SetAttribute('OriginalTransparency', nil)  -- set nil so we know its back to origianl transparency 
			end
		end
		
		if v:IsA("BillboardGui") then
			v.Enabled = true
		end
	end)
	---table.clear(transparentParts)   don't think you need this if you use attributes
end
1 Like

you also don’t even need this if you are setting the attribute somewhere else only on mesh/baseparts

1 Like

Thank you for this, I’m gonna try this out and pray it works : )

it should as long as you are setting it right