Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why are my GUI Buttons not working inside plugin GUI? ikjlkjhjmk,jm

I have created a simple frame with buttons inside to execute some actions and used it as a plugin GUI, the DockWidgetPluginGui.

The event Activated of the buttons are getting connected, but they are not calling the passed function when pressed.

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)

2 answers

Congratulations on finding this out yourself! But be sure to put (Solved) in your title, that way people know it's been solved, instead of instantly going to answers and posting a solution.

I found the problem. I am connecting the event in the original button inside the plugin folder, not the clone made for the plugin GUI.

This discussion is preserved as it was. New answers, comments, and votes are closed.