I’m trying to make a plugin that creates a window when you press the button once and deletes it when you press again.
The problem is tho that I can’t see the widget even though it should be. I’m not sure if the widget is just hidden or something or if it just isn’t appearing at all.
-- [ Services ] ----------------------------------
local ChangeHistoryService = game:GetService("ChangeHistoryService")
--------------------------------------------------
-- [ Variables ] ---------------------------------
local ToolBar = plugin:CreateToolbar("2dMapEditor")
local SettingsButton: PluginToolbarButton = ToolBar:CreateButton("Settings", "Settings", "rbxassetid://12659097301")
local EditButton: PluginToolbarButton = ToolBar:CreateButton("Edit", "Edit", "rbxassetid://109205209769753")
local SettingsWidget = nil
--------------------------------------------------
-- [ Functions ] ---------------------------------
local function SettingsButtonPressed()
if SettingsWidget and SettingsWidget:IsA("DockWidgetPluginGui") then SettingsWidget:Destroy() SettingsWidget = nil warn("Destroying")return
else
warn("Creating")
end
local WidgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
false,
false,
200,
200,
200,
200
)
SettingsWidget = plugin:CreateDockWidgetPluginGui("SettingsWidget", WidgetInfo)
SettingsWidget.Title = "Settings Widget"
end
local function EditButtonPressed()
warn("Pressed EditButton")
end
--------------------------------------------------
-- [ Execute ] -----------------------------------
SettingsButton.Click:Connect(SettingsButtonPressed)
EditButton.Click:Connect(EditButtonPressed)
SettingsButton.ClickableWhenViewportHidden = true
EditButton.ClickableWhenViewportHidden = true
--------------------------------------------------