How to make a plugin 'deselect'

Hey there! I am currently working on a plugin, but there is a small problem - when you click the X button on the plugin widget, it doesn’t de-select the icon on the topbar. Is there anyway to make this happen?

This is my code:

local toolbar = plugin:CreateToolbar("Tech Tunnel")

local pluginButton = toolbar:CreateButton("Open Menu", "This plugin allows you to create stages for Tech Tunnel!", "http://www.roblox.com/asset/?id=6777344784")

local open = false

local Info = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Left,
	false,
	true,
	375,
	350,
	375,
	400
)

local widget = plugin:CreateDockWidgetPluginGui("Tech Tunnel Builder", Info)
widget.Title = "Tech Tunnel Builder"
local frame = script.Parent.MainFrame
frame.Parent = widget

pluginButton.Click:Connect(function()
	widget.Enabled = not widget.Enabled
end)

Thanks

3 Likes

Use plugin:Deactivate() to disable your plugin. You can read more about it here although there’s not really that much to read.

I hope this helped :slight_smile:

For some reason, this doesn’t seem to be working, here is how I have put it into my script:

--------------------------
--//[[ Plugin Setup ]]\\--
--------------------------

--[[ Toolbar setup ]]

local toolbar = plugin:CreateToolbar("Tech Tunnel")

local pluginButton = toolbar:CreateButton("Open Menu", "This plugin allows you to create stages for Tech Tunnel!", "http://www.roblox.com/asset/?id=6777344784")

--[[ Widget Setup ]]--

local Info = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Left,
	false,
	true,
	400,
	350,
	400,
	400
)

local widget = plugin:CreateDockWidgetPluginGui("Tech Tunnel Builder", Info)
widget.Title = "Tech Tunnel Builder"
local frame = script.Parent.MainFrame
frame.Parent = widget

pluginButton.Click:Connect(function()
	widget.Enabled = not widget.Enabled
	if widget.Enabled == false then
		plugin:Deactivate()
	end
end)

use :SetActive()

local toolbar = plugin:CreateToolbar("Test")
local PluginToolbarButton = toolbar:CreateButton("Test","Hi","")
PluginToolbarButton:SetActive(false) -- Unhighlight the button

PluginToolbarButton:SetActive(true) -- highlight the button