I have a ScreenGui that has a lot of ImageLabels, TextLabels, Frames, etc. and I would like to adjust the transparency of ALL objects within that ScreenGui to add a fading effect when entering the game.
So instead of doing each one by line, I'd like to use GetChildren, and find if each child has 1 or more transparency properties, and adjust the transparencies to a set variable if it does.
So here is what I have so far:
function Fade()
for i = 0.05, 1, 0.05 do
for index, child in pairs(script.Parent.Parent:GetChildren()) do --script.Parent.Parent is the ScreenGui
if child.Transparency ~= nil then
child.Transparency = i
end
if child.TextTransparency ~= nil then
child.TextTransparency = i
end
if child.BackgroundTransparency ~= nil then
child.BackgroundTransparency = i
end
if child.ImageTransparency ~= nil then
child.ImageTransparency = i
end
end
wait(0.05)
end
script.Parent.Parent:Destroy()
end

1 comment
That's why I do
if child.Transparency ~= nil thenbut that doesn't work.