So, I've made a plugin that works fine. The GUI opens/closes. But the only problem I'm having is that the buttons in the GUI doesn't work.
Plugin script:
01 | print ( "Part creator plugin loaded!" ) -- I was bored, so I decided to do something random |
02 |
03 | local toolbar = plugin:CreateToolbar( "dragonmaster4111" ) |
04 | local button = toolbar:CreateButton( |
05 | "Create Part" , |
06 | "Click anywhere to insert a part at your mouse position" , |
08 | ) |
09 |
10 | function InsertGUI() |
11 | script.Parent.GUI:Clone().Parent = game.CoreGui |
12 | end |
13 | function RemoveGUI() |
14 | game.CoreGui:FindFirstChild( "GUI" ):Destroy() |
15 | end |
And, the script inside the button that doesn't work when you click it:
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if script.Parent.Parent.Types.Visible ~ = true then |
3 | script.Parent.Parent.Types.Visible = true |
4 | script.Parent.Rotation = 180 |
5 | else |
6 | script.Parent.Types.Visible = false |
7 | script.Parent.Rotation = 0 |
8 | end |
9 | end ) |
Note: This plugin has everything in a folder. The GUI is premade. The script clones it into CoreGui when you click the button in it's toolbar.
Old question but it bothers me when the only reference to a problem I had, has no solution. I was able to resolve this issue by waiting for the GUI in core with:
game.CoreGui.ChildAdded:Connect(function(child)
-- need to use WaitForChild as descendants may not have replicated yet --local head = child:WaitForChild("Head") --guiLocation.ClickerWindow.Frame.TextButton.MouseButton1Click:Connect(insertClickEvent) end)
Example
Below is an example of how a plugin should be structured
01 | print ( "Loading Block Identifier..." ) |
02 |
03 | -- Check if user has loaded plugin before |
04 | local hasLoaded = plugin:GetSetting( "pluginHasLoaded" ) |
05 | if not hasLoaded then |
06 | print ( "Welcome to the Block Identifier. To use this plugin, click on the button in the addon bar, then click on the object you want to inspect." ) |
07 | plugin:SetSetting( "pluginHasLoaded" , true ) |
08 | end |
09 |
10 | -- Setup Toolbar |
11 | local toolbar = plugin:CreateToolbar( "Block Identifier" ) |
12 |
13 | -- Setup button |
14 | local button = toolbar:CreateButton( |
15 | "Button" , |
I believe event you used in line 1 of the script inside of the button should instead be MouseButton1Down:
script.Parent.MouseButton1Down:connect(function()