Transparency Control Module

Overview

I am sure every gui designer has wanted to make fade in and fade out gui because thats basically the best possible transisition in gui design to history, undebateable. So I made a module for it.

local TransparencyControlAdder = {}

function TransparencyControlAdder.Add(Object:GuiObject)
	for i,v in pairs(Object:GetDescendants()) do
		if v:IsA("GuiObject") then
			if v.BackgroundTransparency < 1 then
				if not v:FindFirstChild("BackgroundTransparency") then
					local bgt = Instance.new("NumberValue")
					bgt.Name = "BackgroundTransparency"
					bgt.Parent = v
					bgt.Value = v.BackgroundTransparency
				end
			end
			if v:IsA("TextLabel") or v:IsA("TextButton") or v:IsA("TextBox") then
				if v.TextTransparency < 1 then
					if not v:FindFirstChild("TextTransparency") then
						local tt = Instance.new("NumberValue")
						tt.Name = "TextTransparency"
						tt.Parent = v
						tt.Value = v.TextTransparency
					end
				end
			elseif v:IsA("ImageLabel") or v:IsA("ImageButton") or v:IsA("ViewportFrame") then
				if v.ImageTransparency < 1 then
					if not v:FindFirstChild("ImageTransparency") then
						local it = Instance.new("NumberValue")
						it.Name = "ImageTransparency"
						it.Parent = v
						it.Value = v.ImageTransparency
					end
				end
			elseif v:IsA("ScrollingFrame") then
				if v.ScrollBarImageTransparency < 1 then
					if not v:FindFirstChild("ScrollBarImageTransparency") then
						local sbit = Instance.new("NumberValue")
						sbit.Name = "ScrollBarImageTransparency"
						sbit.Parent = v
						sbit.Value = v.ScrollBarImageTransparency
					end
				end
			end
		end
	end
end

function TransparencyControlAdder.AddToSelected()
	for i,v in pairs(game:GetService("Selection"):Get()) do
		TransparencyControlAdder.Add(v)
	end
end

function TransparencyControlAdder.Tween(o,d,g)
	game:GetService("TweenService"):Create(o,TweenInfo.new(d),g):Play()
end

function TransparencyControlAdder.ControlTransparency(Of:GuiObject | "Instances from the Add function",In:number | "Duration",To:number | "Transparency")
	for i,v in pairs(Of:GetDescendants()) do
		if v:IsA("NumberValue") and string.find(v.Name,"Transparency") then
			TransparencyControlAdder.Tween(v.Parent,In,{[v.Name] = math.clamp(To,v.Value,1)})
		end
	end
end

return TransparencyControlAdder

How to use?

You can run the Add function to add the TransparencyControlModifiers.

Using the AddToSelected function allows you to add them in studio using the command panel. Simply type require(path2module).AddToSelected while selecting your gui’s.

The Tween function is just a quick tween function.

The ControlTransparency allows you to control the transparency of the guis affected by the TCM (TransparencyControlModifiers [as I like to call them])

And thats all!

How is this better than any other module?

Idk its not? I haven’t seen any such modules here. Also I know you can do this with attributes and they are much lighter bla bla bla I won’t do it because well its now on you to update the module to your liking.

Poll

  • Epic module! I needed this so bad!
  • Epic module! I didn’t need this as I am not a gui designer.
  • Bad module.

0 voters

[P.S] Another tiny winy post I made.

1 Like

This is better than using CanvasGroups which can suddenly cause memory leaks iirc [I don’t care about memory leaks]

1 Like

What’s canvas groups lol.

Ahhhh so this is better than that?

I heard that there are memory leaks for that instance. Not sure if it’s true

can you provide a video of the module in action?

It’s just a simple fade in and out module there is nothing too special about it that should be documented in a video.

But anyways:


(Footage from a game I am working on.) As you can see the tab fade in/out animations are done by this module.

9 Likes