You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
When you press the plugin icon/button a window should be created with the provided properties.
What is the issue?
The window does not show up but if you click it two times it will give you an error
informing you that there is already a created window with that same name.
The server script/plugin:
local toolbar = plugin:CreateToolbar("run")
local button = toolbar:CreateButton("","","http://www.roblox.com/asset/?id=my_id")
local window_info = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
false,
800,
350,
1280,
720
)
function OnpluginClicked()
local window = plugin:CreateDockWidgetPluginGui("test", window_info)
end
button.Click:Connect(OnpluginClicked)
Try changing the Enabled property to make the widget visible. I’d also like to mention that you can’t create widgets with the same name, which is why it errors. You would want to create the widget upon initialization of the plugin and disable it, then when you want to bring it up, enable it:
local window_info = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
false,
false,
800,
350,
1280,
720
)
local window = plugin:CreateDockWidgetPluginGui("test", window_info)
function OnpluginClicked()
window.Enabled = true
end
You need to create the dockwidgetplugingui before the button gets clicked. You should also enable the plugin gui when the toolbar button is activated.
Here is the code I would usually use to create plugin window
local Toolbar = plugin:CreateToolbar("Click me")
local Button = Toolbar:CreateButton("", "", "", "")
local Opened = false
local WidgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Left,
false, -- Widget will be initially enabled
false, -- Don't override the previous enabled state
200, -- Default width of the floating window
300, -- Default height of the floating window
150, -- Minimum width of the floating window (optional)
150 -- Minimum height of the floating window (optional)
)
local Widget = plugin:CreateDockWidgetPluginGui("", WidgetInfo)
Widget.Title = ""
Button.Click:Connect(function()
if Opened then
Widget.Enabled = false
Opened = false
else
Widget.Enabled = true
Opened = true
end
end)