How i can hide, and then show back widget?

Hello. I’m trying make my own plugin. Sadly, I can’t find anything understandable, but only empty API reference and tutorials with nothing descreptive enough. Can someone say me, how I can hide, and then show again widgets?

I haven’t made plugins before, so this is probably completely wrong.
But is there a visible property of widgets?

Nope, they haven’t visible property.

I did some research and found something, does widget.Enabled work?

1 Like
local Toolbar = plugin:CreateToolbar("MyPlugin")
local Button = Toolbar:CreateButton("MyPlugin", "Description", "rbxassetid://", "Plugin")
local Opened = false

local PluginWidgetInfo = 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
	245,    -- Minimum width of the floating window (optional)
	200     -- Minimum height of the floating window (optional)
)


local Widget = plugin:CreateDockWidgetPluginGui("Not", WidgetInfo)
Widget.Title = "My plugin"
local Gui = script.Parent.Frame
Gui.Parent = Widget

Button.Click:Connect(function()
	if Opened then
		Widget.Enabled = false
		Opened = false
	else
		Widget.Enabled = true
		Opened = true
	end
end)
local Opened = false

Button.Click:Connect(function()
	if Opened then
		Widget.Enabled = false
		Opened = false
	else
		Widget.Enabled = true
		Opened = true
	end
end)
2 Likes

I can’t this test rn, bc my previous widget is enabled, but closed, and I can’t create new one. is it possible to get previous widget, if I updated plugin?

You could create a variable for it when it’s closed

1 Like

I updated plugin, widget1 is still exist, I can’t open it, and plugin’s script have Opened value of false, but I can’t create new widget2, bc widget1 exist.

This is the solution

local Opened = false

Button.Click:Connect(function()
	if Opened then
		Widget.Enabled = false
		Opened = false
	else
		Widget.Enabled = true
		Opened = true
	end
end)
1 Like

Yes, but I can’t test it due to problem that widget already created, but after updating plugin, it got erased from script’s variable, and throws error that widget already exists, but IDK how get that existing widget.

So your problem is something else

AAAAAAA

Show me this

1 Like

Where I should find something like this?

Also, code which I have.

local toolbar = plugin:CreateToolbar("Custom Terrain Tools")

local OpenTerrainEditor = toolbar:CreateButton("Terrain Editor Remastered", "Terrain Editor with upgraded functions!", "http://www.roblox.com/asset/?id=10514571675")

OpenTerrainEditor.ClickableWhenViewportHidden = true

local Widget
local Opened = false

local function SynchronizeColors(objects)
	local function SetColors()
		for _, guiObject in pairs(objects) do
			-- Sync background color
			guiObject.BackgroundColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainBackground)
			-- Sync text color
			if guiObject:IsA("TextLabel") or guiObject:IsA("TextButton") or guiObject:IsA("TextBox") then
				guiObject.TextColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainText)
			end
		end
	end
	-- Run 'setColors()' function to initially sync colors
	SetColors()
	-- Connect 'ThemeChanged' event to the 'setColors()' function
	settings().Studio.ThemeChanged:Connect(SetColors)
end

local function Open()
	if Widget == nil and Opened == false then
		local widgetInfo = DockWidgetPluginGuiInfo.new(
			Enum.InitialDockState.Right,  -- Widget will be initialized in floating panel
			true,   -- 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
			150     -- Minimum height of the floating window
		)

		-- Create new widget GUI
		Widget = plugin:CreateDockWidgetPluginGui("TerrainEditorRemastered", widgetInfo)
		Widget.Title = "Terrain Editor Remastered"  -- Optional widget title
		local Background = Instance.new("Frame")
		SynchronizeColors({Background})
		Background.Size = UDim2.new(1, 0, 1, 0)
		Background.BorderSizePixel = 0
		Background.Parent = Widget
		Opened = true
	elseif Opened == true then
		Widget.Enabled = false
		Opened = false
	elseif Opened == false then
		Widget.Enabled = true
		Opened = true
	end
end

OpenTerrainEditor.Click:Connect(Open)

Try this.

local toolbar = plugin:CreateToolbar("Custom Terrain Tools")

local OpenTerrainEditor = toolbar:CreateButton("Terrain Editor Remastered", "Terrain Editor with upgraded functions!", "http://www.roblox.com/asset/?id=10514571675")

OpenTerrainEditor.ClickableWhenViewportHidden = true

local Opened = false


local function SynchronizeColors(objects)
	local function SetColors()
		for _, guiObject in pairs(objects) do
			-- Sync background color
			guiObject.BackgroundColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainBackground)
			-- Sync text color
			if guiObject:IsA("TextLabel") or guiObject:IsA("TextButton") or guiObject:IsA("TextBox") then
				guiObject.TextColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainText)
			end
		end
	end
	-- Run 'setColors()' function to initially sync colors
	SetColors()
	-- Connect 'ThemeChanged' event to the 'setColors()' function
	settings().Studio.ThemeChanged:Connect(SetColors)
end

local function Open()
		    local widgetInfo = DockWidgetPluginGuiInfo.new(
			Enum.InitialDockState.Right,  -- Widget will be initialized in floating panel
			true,   -- 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
			150     -- Minimum height of the floating window
		)

		-- Create new widget GUI
		Widget = plugin:CreateDockWidgetPluginGui("TerrainEditorRemastered", widgetInfo)
		Widget.Title = "Terrain Editor Remastered"  -- Optional widget title
		local Background = Instance.new("Frame")
		SynchronizeColors({Background})
		Background.Size = UDim2.new(1, 0, 1, 0)
		Background.BorderSizePixel = 0
		Background.Parent = Widget
end

OpenTerrainEditor.Click:Connect(function()
	if Opened then
		Widget.Enabled = false
		Opened = false
	else
		Widget.Enabled = true
		Opened = true
	end
end)

OpenTerrainEditor.Click:Connect(Open)
1 Like