How to make every GUI fade out?

  1. What do you want to achieve? For every GUI to fade out, without painstakingly defining each and every one of the GUIs.

  2. What is the issue? I don’t know how to define every single GUI and it’s children to change it’s transparency.

  3. What solutions have you tried so far? I’ve tried using the “for i, v” method which is the only method I know into getting the children of instances.

local function Takeover()
		ToggleDialogueEvent:FireAllClients(true)
		DialogueEvent:FireAllClients("Agent: Looks like he didn't make it...")
		wait(3.5)
		DialogueEvent:FireAllClients("Agent: Check for more informa-")
		wait(2)
		ToggleDialogueEvent:FireAllClients(false)

        -- where i want GUIs to fade out

	end

Yes I’ve tried researching for this but unfortunately I couldn’t find any solutions. Any help is appreciated!

you can use this, loop via all the GUIs and put this code

game:GetService("TweenService"):Create(GUI, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {BackgroundTransparency = 1)

this might help? Hope so.

local ScreenGui = script.Parent -- ScreenGui

local TweenService = game:GetService("TweenService")
local TweenInfoFade = TweenInfo.new(
	0.5, -- Fade Time
	Enum.EasingStyle.Sine, 
	Enum.EasingDirection.Out
)

local Tag = {
	["Frame"] = {
		["BackgroundTransparency"] = 1,
	},
	[{"TextLabel", "TextBox", "TextButton"}] = {
		["BackgroundTransparency"] = 1,
		["TextTransparency"] = 1,
		["TextStrokeTransparency"] = 1
	},
	[{"ImageLabel", "ImageButton"}] = {
		["BackgroundTransparency"] = 1,
		["ImageTransparency"] = 1
	},
	["UIStroke"] = {
		["Transparency"] = 1
	}
}

for i,v in pairs(ScreenGui:GetDescendants()) do
	for i2,v2 in pairs(Tag) do
		if typeof(i2) == "table" then
			for i3,v3 in pairs(i2) do
				if v:IsA(v3) then
					local Tween = TweenService:Create(
						v,
						TweenInfoFade,
						Tag[i2]
					):Play()
				end
			end
		else
			if v:IsA(i2) then
				local Tween = TweenService:Create(
					v,
					TweenInfoFade,
					Tag[i2]
				):Play()
			end
		end
	end
end
2 Likes

You could make use of CanvasGroups, then tween the GroupTransparency to smoothly change the transparency of UI objects. However, there’s a bug where the descendants of CanvasGroups are pixelated with lower graphics levels.

Thanks man! Didn’t know this would be so complicated.

1 Like

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