Button not deactivating inside Button.Click()

Here is a very simple plugin, I am attempting to deactivate not disable the plugin button inside the PluginToolbarButton.Click() event, however it is not working, instead nothing is disabled.

local toolbar : PluginToolbar = plugin:CreateToolbar("awef")

local firstButton : PluginToolbarButton = toolbar:CreateButton("hello","","","hello")
local secondButton : PluginToolbarButton = toolbar:CreateButton("second","","","second")

local widgetInfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,
	false,
	false,
	300,
	228,
	300,
	228
)

local widget

firstButton.Click:Connect(function()
	
	widget = plugin:CreateDockWidgetPluginGui("titleawed",widgetInfo)
	widget.Title = "This is the real title"	
	widget.Enabled = true
	
	widget:BindToClose(function()
		firstButton:SetActive(false)
	end)
end)
1 Like

Try using widget:GetPropertyChangedSignal("Enabled") instead of BindToClose.

2 Likes

The issue is not so much about the Event itself, the issue comes from the firstButton:SetActive(false) instead of deactivating the firstButton nothing actually happens. I did try your solution out of curiosity, but no luck.

1 Like

Why are you doing it within the Click event btw?

Usually you’d want to have the widget already created and just Enable and Disable it when clicked.

2 Likes

ye, except I’m trying to make it disable when you press the X button on the widget

I have actually tried it outside of the .Click() in a bind to close and it’s still not deactivating it, it’s quite weird, I’ll try doing it with property changed as well

1 Like

What do you mean by “disable”?

2 Likes

So that the plugin image/text in the plugin tool bar is no longer “highlighted” via “SetActive()”

1 Like
local gui = ...
local toggleButton = ...

gui:GetPropertyChangedSignal("Enabled"):Connect(function()
  toggleButton:SetActive(gui.Enabled)
end)

This is from one of my plugins and it does work

3 Likes

oh boyo, that actually worked, I wonder why it doesn’t work in Click() or BindToClose(), very odd, thank you so much!

2 Likes