Why are my GUI Buttons not working inside plugin GUI?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
  • I have created a simple frame with buttons inside to execute some actions and used it as a plugin GUI, the DockWidgetPluginGui.
  1. What is the issue? Include screenshots / videos if possible!
  • The event Activated of the buttons are getting connected, but they are not calling the passed function when pressed.
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
  • I have tried changing the event to MouseButton1Click, MouseButton1Down and others, they do not fire as well. I have tried changing the script to a Script instead of LocalScript, nothing changes.

Details:

-- setting basic plugin script:

local ChangeHistoryService = game:GetService("ChangeHistoryService")

local Folder = script.Parent.PluginGuiFolder
local Frame = Folder.Frame

local Selection = game:GetService("Selection")

local widgetinfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,
	false,   
	false, 
	250, 
	210,    
	250,    
	210		
)

local PluginGui = plugin:CreateDockWidgetPluginGui("GUITools", widgetinfo)
PluginGui.Title = "GUI Tools"

for i, v in pairs(script.Parent.PluginGuiFolder:GetChildren()) do
	v:Clone().Parent = PluginGui
end

local Toolbar = plugin:CreateToolbar("GUI Tools")

local PluginButton = Toolbar:CreateButton(
	"Gui Tools",
	"Tools for quick editing GUI.",
	"rbxassetid://6795025905",
	"Gui Tools") 
PluginButton.ClickableWhenViewportHidden = true

local function disc(x)
	if x then x:disconnect() end
end

PluginButton.Click:Connect(function()
	if not PluginGui.Enabled then
		PluginGui.Enabled = true
	else
		PluginGui.Enabled = false
	end
end)

PluginGui.Changed:Connect(function(property)
	if property == "Enabled" then
		PluginButton:SetActive(PluginGui.Enabled)
	end
end)

-- Button Connection: --------------------------------------------------------------------------------------------

Frame.Centralize.Activated:Connect(function() -- "Centralize" is the name of the button.
    print("Pressed") -- does not fire when pressed, no errors in output
end)

I found the problem, I am connecting the event in the original template button, not the clone I made in the pluguin GUI.

1 Like