PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

BackgroundTransparency

GuiObject

float

This property determines the transparency of the GuiObject|GUI's background and border.

It does not, however, determine the transparency of text if the GUI is a Textbox, TextButton, or TextLabel. Text transparency is determined TextBox/TextTransparency|, TextButton/TextTransparency, and TextLabel/TextTransparency respectively.

If the property is set to 1, neither the background nor the border will render and the GUI will be completely transparent.


Code Samples


Flash Fade a Gui Element

The example below demonstrates how to continuously fade a GUI element in and out (see image below). It relies on the RenderService|RenderService's RenderService/RenderStepped event to update and render the element’s GuiObject/BackgroundTransparency every frame.

The GUI element fades in and out between the maximum transparency value, MAX_TRANSPARENCY, and minimum transparency value, MIN_TRANSPARENCY. It uses the delta variable to determine what amount to change the element’s BackgroundTransparency.

This example should work as expected when placed in a Script or LocalScript that is the child of the GUI element you want to fade in and out.

GUI Element Fading In and Out

local RunService = game:GetService("RunService")

local MIN_TRANSPARENCY = 0
local MAX_TRANSPARENCY = 0.9
local delta = 0

local function fadeGui()
	local element = script.Parent
	
	if element.BackgroundTransparency <= MIN_TRANSPARENCY then 
		delta = 0.01
	elseif element.BackgroundTransparency >= MAX_TRANSPARENCY then
		delta = -0.01
	end
	
	element.BackgroundTransparency = element.BackgroundTransparency + delta
end

RunService.RenderStepped:Connect(fadeGui)