How can I make the whole GUI Fade in?

Hey there!

I want my WHOLE GUI to fade in when a function is called. It’s not possible to make the Transparency of the frame from 1 to 0 for the elements in it to also fade in.

How would I achieve this without needing the reference every element in the frame and change their transparency.

Thank you so much!

2 Likes

Maybe something like this

for i, element in pairs(frame:GetDescendants()) do
    if element:IsA('GuiBase2d') then
        element.Transparency = frame.Transparency
    end
end

Put this in a loop until frame.Transparency is 0 (i wrote this on mobile so not sure if it works)

3 Likes

Yeah, this is the method I am familiar with; I don’t think there’s a simple function or method that allows you to change transparency without referencing the elements at all (via a loop or anything). A loop over descendants definitely works. Only minor tweak I would make is as follows, depending on what you want:

  1. If you want to basically link the transparency of all the inner elements to the main frame at all times, you should do this:
for _, elmement in ipairs(frame:GetDescendants()) do
  if element:IsA("GuiBase2d") then
    frame:GetPropertyChangedSignal("Transparency"):Connect(function()
      element.Transparency = frame.Transparency
    end)
  end
end
  1. If you want to only change the transparency at particular times, you should do this:
local function decreaseOpacityOf(element: GuiBase2d)
  -- Logic to decrease the opacity; maybe via a tween or just instantaneously
end

local function decreaseOpacityOfAllElements(frame: Frame)
  decreaseOpacityOf(frame)
  for _, element in ipairs(frame:GetDescendants()) do
    if element:IsA("GuiBase2d") then
      decreaseOpacityOf(element)
    end
  end
end
5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.