Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Adjusting ScreenGui Transparency?

Asked by
GShocked 150
9 years ago

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 answer

Log in to vote
0
Answered by 9 years ago

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.

0
That's why I do `if child.Transparency ~= nil then` but that doesn't work. GShocked 150 — 9y
Ad

Answer this question