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

Active

GuiObject

bool

Active determines whether a UI element will sink input to other UI elements underneath the object, or the 3D space itself (such as underlying models with a ClickDetector). In the case of GuiButton objects, this will determine whether or not GuiButton/Activated fires. However, GuiButton/AutoButtonColor will still partially work.

For example, if a Frame with Active set to true covers a TextButton with Active also set to true, clicks over the Frame and TextButton it will not reach the TextButton. The Frame “sinks” the input. Disabling Active on the Frame will allow a click to ignore the Frame and continue to the TextButton. In general, if you want an Active button to be clickable, be sure the button is not obscured by another Active element. Conversely, if you do not want anything under a UI element (such as a pop-up window) to be clickable, set Active to true to prevent this.


Code Samples


TextButton Active Debounce

This code sample demonstrates the usage of the Active property as a debounce for the Activated event.

-- Place this LocalScript within a TextButton (or ImageButton)
local textButton = script.Parent

-- Initialize the state of the button
textButton.Text = "Click me"
textButton.Active = true

local function onActivated()
	-- Prevent future Activations
	-- This acts like a debounce
	textButton.Active = false

	-- Count backwards from 5
	for i = 5, 1, -1 do
		textButton.Text = "Time: " .. i
		wait(1)
	end
	textButton.Text = "Click me"
	
	-- Allow activations again
	textButton.Active = true
end

textButton.Activated:Connect(onActivated)