Plugin Widget unable to open again when closed

Hello, I’m starting to script lua widgets for my next plugin. For some reason the Dock UI won’t appear anymore as soon as I close it and open it again. I’ve tried making some changes to the code and the design, nothing seemed to work.
The error I keep getting in the “output” window is

19:30:45.877 - This plugin cannot create more than one PluginGui with id: "Ellipse"
19:30:45.878 - Stack Begin
19:30:45.878 - Script 'Plugin_EllipsePlus.rbxmx.Ellipse+.PluginCreator', Line 32 - function MenuShow
19:30:45.878 - Script 'Plugin_EllipsePlus.rbxmx.Ellipse+.PluginCreator', Line 50
19:30:45.879 - Stack End

Heres a video to show the problem in action.


Any suggestions? Thanks!

1 Like

You can probably attach an incrementing variable to the Id, like: WidgetName.. num

num will increase by 1 each time the widget is created

When the button is clicked, you should change Widget.Enabled to true instead of creating a new widget (which isn’t possible with the same name)

local toolbar = plugin:CreateToolbar("Toolbar")
local button = toolbar:CreateButton("Whatever", "...", "rbxassetid://87654321")

local widget = plugin:CreateDockWidgetPluginGui(info)

button.Click:Connect(function()
    widget.Enabled = not widget.Enabled
end)
3 Likes

This actually worked! Thank you for the suggestion, I’ll mark this as the solution.