Plugin won't let me create Widgets

So, I’m wanting to create a simple plugin that will allow me to change the font of the output window.

whenever I click the button on the toolbar, nothing shows up, when I click it again, I get the error:

" This plugin cannot create more than one PluginGui with id: “Output”](rbxopenscript://www.dummy.com/dummy?scriptGuid=%7B3147EE54-08E8-4064-A1A6-EF55C7664CDE%7D&gst=6#10)"

I’ve looked at the Dev hub, and this error doesn’t seem to appear, so I’m just asking for possible solutions, cause all the YouTube tutorials I watch don’t have this problem cause they aren’t dealing with widgets.

Here’s my code:

print("Output changer loaded!")

local Toolbar = plugin:CreateToolbar("DoctorNO2106")

local Button = Toolbar:CreateButton("Output", "Output font", "rbxgameasset://Images/Output font")

Button.Click:Connect(function()
	local DWPINFO = DockWidgetPluginGuiInfo.new(	Enum.InitialDockState.Right, true,   false,  300,    300,    150,    150)
	
	local Widgit = plugin:CreateDockWidgetPluginGui("Output", DWPINFO)
	
	Widgit.Title = "Change Output Font."
	
	local testButton = Instance.new("TextBox")
testButton.BorderSizePixel = 0
testButton.TextSize = 20
testButton.TextColor3 = Color3.new(1,0.2,0.4)
testButton.AnchorPoint = Vector2.new(0.5,0.5)
testButton.Size = UDim2.new(1,0,1,0)
testButton.Position = UDim2.new(0.5,0,0.5,0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Enter Font type"
testButton.Parent =  Widgit
end)

If there’s something I’m missing please let me know, :slightly_smiling_face:

1 Like

You can’t use plugins running in game. Make sure to save it as a local plugin then run it in studio

1 Like

I guess I should of clarified, I am saving it as a local plugin, and nothing is happening.

1 Like

The error message implies that you are trying to create a plugin widget with a widget id that already exists. Try changing the widget id to something else.

2 Likes

So, that kinda worked, it only showed up once, and even if I press the X on it, and click the button again, it won’t show another widget.

Yeah, you can only have one PluginGui with the same name. You can append os.time() or something similar to the “Output” string so that it’s unique each time.

3 Likes

Thanks! I’ll try that! :slightly_smiling_face:

You are creating the Gui for each Event, no wonder this is not working.

Its like this:
You have a box of diamonds in it, then, after the event is finished, you empty the box and want to fill it with diamonds again. You know that’s not the best method (and pretty expensive, you are always buying diamonds lol)? Create it outside the event and manipulate it when you look at it simply by using the .Enabled property, it’s that easy, and that’s how you prevent memory leaking.


local Toolbar = plugin:CreateToolbar("DoctorNO2106")
local isOn = false --new property
local Button = Toolbar:CreateButton("Output", "Output font", "rbxgameasset://Images/Output font")
--Create here your Widget
	local DWPINFO = DockWidgetPluginGuiInfo.new(	Enum.InitialDockState.Right, true,   false,  300,    300,    150,    150)
	
	local Widgit = plugin:CreateDockWidgetPluginGui("Output", DWPINFO)
	
	Widgit.Title = "Change Output Font."
	
	local testButton = Instance.new("TextBox")
testButton.BorderSizePixel = 0
testButton.TextSize = 20
testButton.TextColor3 = Color3.new(1,0.2,0.4)
testButton.AnchorPoint = Vector2.new(0.5,0.5)
testButton.Size = UDim2.new(1,0,1,0)
testButton.Position = UDim2.new(0.5,0,0.5,0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Enter Font type"
testButton.Parent =  Widgit


Button.Click:Connect(function()
    isOn = not isOn
    DWPINFO.Enabled = isOn
end)

1 Like

Thanks! This really helped! I didn’t even know there was an enabled property for widgets lol

Here you can find all properties, make sure that if you not know something, that you search it here!

This API documentation is really helpfulll

Thanks! :slightly_smiling_face:

1 Like