How can I disable a UI button?

To make it inactive, no hover effect, no effect on click and attached events are not fired. Any ideas? Workarounds?

You can just use:

for i,v in pairs(game.Players:GetPlayers()) do
    v.PlayerGui.ScreenGui.ImageButton.Enabled = false
end

To temporarily disable it for all players.

2 Likes

Hmm. Really there is a option Enabled? I just saw “Active” bool

Yes , there is Enabled function so you can disable it and it won’t work for all players without any scripts for that .

1 Like

How it’s not documented > TextButton | Documentation - Roblox Creator Hub ? I think you both mean “Active” bool? In conjuction with AutoButtonColor = false, seems to work well.

2 Likes

There is no enabled property for a textbutton, the only way you can achieve this is by a custom solution, what you should do is make a variable in the script managing the button, which holds if the button is enabled, and check if the button is enabled before acting on any input. Right now there is no property that can completely sink input (GuiObject 'Enabled' property - a feature request made a long time ago). To make this easier to script only detect input using the input began event:

local TextButton = --some text button
local Enabled = true

TextButton.InputBegan:Connect(function(Input)
    if (not Enabled) then
        return
    end
    --detect other input events using Input.UserInputType
end)
3 Likes

There is no “Enabled” function, what I did is I made a TextLabel that looks exactly like the TextButton, then when it’s clicked, TextButton.Visile = false and TextLabel.Visible = true.

7 Likes