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

Active

GuiObject

bool

This property determines whether a GuiObject will sink input to 3D space, such as underlying models with a ClickDetector. In other words, if the player attempts to click a ClickDetector with the mouse hovering over an Active UI element, the UI will block the input from reaching the ClickDetector.

For GuiButton objects (ImageButton and TextButton), this property determines whether GuiButton/Activated fires (GuiButton/AutoButtonColor will still work for those as well). The events GuiObject/InputBegan|InputBegan, GuiObject/InputChanged|InputChanged, and GuiObject/InputEnded|InputEnded work as normal no matter the value of this property.


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)