Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Why don't the buttons in the GUI in my plugin work?

Asked by 8 years ago

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:

01print("Part creator plugin loaded!") -- I was bored, so I decided to do something random
02 
03local toolbar = plugin:CreateToolbar("dragonmaster4111")
04local button = toolbar:CreateButton(
05    "Create Part",
06    "Click anywhere to insert a part at your mouse position",
08)
09 
10function InsertGUI()
11    script.Parent.GUI:Clone().Parent = game.CoreGui
12end
13function RemoveGUI()
14    game.CoreGui:FindFirstChild("GUI"):Destroy()
15end
View all 22 lines...

And, the script inside the button that doesn't work when you click it:

1script.Parent.MouseButton1Click: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
9end)

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.

1
Why a downvote? At least tell me what I need to change. Operation_Meme 890 — 8y

3 answers

Log in to vote
1
Answered by 5 years ago

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)

Ad
Log in to vote
0
Answered by 8 years ago

Example

Below is an example of how a plugin should be structured

01print("Loading Block Identifier...")
02 
03-- Check if user has loaded plugin before
04local hasLoaded = plugin:GetSetting("pluginHasLoaded")
05if 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)
08end
09 
10-- Setup Toolbar
11local toolbar = plugin:CreateToolbar("Block Identifier")
12 
13-- Setup button
14local button = toolbar:CreateButton(
15    "Button",
View all 35 lines...
0
Yes, but that still doesn't fix my problem about the buttons. Operation_Meme 890 — 8y
Log in to vote
-1
Answered by 8 years ago

I believe event you used in line 1 of the script inside of the button should instead be MouseButton1Down: script.Parent.MouseButton1Down:connect(function()

0
Pretty sure MouseButton1Down and MouseButton1Click do the same thing. But I'll try anyway. Operation_Meme 890 — 8y

Answer this question