I have a ScreenGui
that has a lot of ImageLabel
s, TextLabel
s, Frame
s, 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
It depends on what is in the ScreenGui. You will need to find if the thing you are changing transparency is a TextLabel/Button/Box (For the text ones) or an ImageLabel (For the image label) OR both, depending on what else is in the ScreenGui (for the background). I can't quite remember how to do this, try the wiki. If not, just write it out. I do it all the time.