Hello,
I am currently trying to create a plugin. I’m very new to plugin creation (I am touching it for the first time today). I’ve created a PluginToolbar
, and then a PluginToolbarButton
. I have built a functionality to happen when I click the button. I was then, in testing, attempting to edit the functionality of the button to make it immediately leave the “pressed” state. This isn’t necessary, but for the sake of looks I wanted it to be pressed, and then immediately set itself to the unpressed state.
In looking through the DevHub, I have found the function :SetActive()
, which is a method of PluginToolbarButton
. On the page it seemed as though this function could set the visual state of the button. It doesn’t do that…
Here is my script:
--Creating the toolbar/buttons
local toolbar = plugin:CreateToolbar("Test")
local button = toolbar:CreateButton("OpenUi", "Opens the UI", "rbxassetid://9081569014","OPEN UI")
button.Enabled = true
button.ClickableWhenViewportHidden = true
--Creating the Widget
local DockInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, false, 200, 200, 100, 100)
local Widget = nil
local function createWidget()
Widget = plugin:CreateDockWidgetPluginGui("TestUi", DockInfo)
Widget.Title = "Test"
Widget.ResetOnSpawn = false
end
local function onButtonClicked()
print("Button clicked")
if not Widget then
createWidget()
end
button:SetActive(false)
Widget.Enabled = not Widget.Enabled
end
button.Click:Connect(onButtonClicked)
Is there a different function I can use to achieve this? I’ve seen this kind of behavior before, so I’m inclined to believe it’s possible.
Thanks in advance for the help!