Sorry for wasting your time for something so simple (in theory);
But I am currently making a system which involves changing the transparency of all visible parts of a character to one through holding down a key. I want to know how I would go about the other portion of the system, making the previously transparent parts regain their previous transparency.
In other words, how would I loop through all instances with a transparency below 1, and “store” it so I can eventually make it visible again?
Do keep in mind I am going for “storage” of what once was previously visble as opposed to looking for transparent parts in the second half of the system (as some parts of the character will be invisible)
1 Like
Suppose you call GetChildren()
or GetDescendants()
on the model, and then store that returned array in a variable like this:
local chrDescendants = chr:GetDescendants()
Now, you can make another array which serves the sole purpose of saving the transparency of items in the chrDescendants
array:
local chrDescTransparency = {}
for index, desc in pairs(chrDescendants) do
if not desc:IsA("BasePart") then continue end
chrDescTransparency[index] = desc.Transparency
end
To “load” the stored transparency values, you can do something like this:
for index, savedTransparency in pairs(chrDescTransparency) do
chrDescendants[index].Transparency = savedTransparency
end
chrDescTransparency = {}
Hope this helps!
6 Likes
This worked! I can’t even begin to say how much time you’ve saved me (and hopefully others) by looking for the answer. 
2 Likes