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

Visible

GuiObject

bool

The Visible property determines whether a UI element will render shapes, images and/or text on screen. If set to false, no descendant GuiObject will render either. The rendering of individual parts of a UI element can be controlled individually through transparency properties such as Frame/BackgroundTransparency, TextLabel/TextTransparency or ImageLabel/ImageTransparency.

A GuiObject that is not Visible will also be ignored by UIGridStyleLayout objects (such as UIGridLayout, UIListLayout and UITableLayout). In other words, the space that the element would otherwise occupy in the layout is used by other elements instead.


Code Samples


UI Window

This code sample adds open/close functionality to a Window UI. Paste as a LocalScript that is a sibling of a Frame named Window, a TextButton/ImageButton named Window, and a TextButton/ImageButton within the Window called Close.

local gui = script.Parent
local window = gui:WaitForChild("Window")
local toggleButton = gui:WaitForChild("ToggleWindow")
local closeButton = window:WaitForChild("Close")

local function toggleWindowVisbility()
	-- Flip a boolean using the `not` keyword
	window.Visible = not window.Visible
end

toggleButton.Activated:Connect(toggleWindowVisbility)
closeButton.Activated:Connect(toggleWindowVisbility)

Blink UI Element

This code sample blinks a UI element on/off, much like HTML’s beloved tag. They still have that, right?

local guiObject = script.Parent

while true do
	guiObject.Visible = true
	wait(1)
	guiObject.Visible = false
	wait(1)
end