I need help with Plugin Guis

I’ve made a plugin that creates a gui which then you can click to do a certain thing but the problem is, is that when I click it nothing happens.
Here is the script I have

local A = plugin:CreateToolbar("Hidden Name"):CreateButton("Hidden Name", "Hidden Desc", "Hidden Asset")

A.Click:Connect(function()
	local NewGui = Instance.new("ScreenGui")
	local InstructionsLabel = Instance.new("TextButton")
	local B = Instance.new("TextBox")
	NewGui.Parent = game.StarterGui
	InstructionsLabel.Parent = NewGui
	InstructionsLabel.Size = UDim2.new(1,0,1,0)
	local S = Instance.new("LocalScript")
	S.Parent = InstructionsLabel
	S.Source = [[script.Parent.MouseButton1Click:Connect(function()
	print("eyyyyy")
end)
]]
end)

I have also tried this with normal scripts

local A = plugin:CreateToolbar("Hidden Name"):CreateButton("Hidden Name", "Hidden Desc", "Hidden Asset")

A.Click:Connect(function()
	local NewGui = Instance.new("ScreenGui")
	local InstructionsLabel = Instance.new("TextButton")
	local B = Instance.new("TextBox")
	NewGui.Parent = game.StarterGui
	InstructionsLabel.Parent = NewGui
	InstructionsLabel.Size = UDim2.new(1,0,1,0)
	local S = Instance.new("Script")
	S.Parent = InstructionsLabel
	S.Source = [[script.Parent.MouseButton1Click:Connect(function()
	print("eyyyyy")
end)
]]
end)

I’m pretty fresh to plugins so I don’t know how to create one where the buttons work in studio.

1 Like

I use [[ so I can add lines to it, like with " if I skipped a line like this

then it wouldn’t work. Even when using [[ and ]] the script still goes in there fine because I look in the script after using the plugin.

Simple, the Script doesn’t run because you’re in edit mode.

Your Script for the plugin Toolbar here can actually Connect on MouseButton1Click itself with no problems; no reason to use any other Scripts.

1 Like

The plugin is working fine. Since scripts created in runtime execute only in play mode not in the studio.
You can archive the effect that you want by using the following code instead:

local A = plugin:CreateToolbar("Hidden Name"):CreateButton("Hidden Name", "Hidden Desc", "Hidden Asset")

A.Click:Connect(function()
	local NewGui = Instance.new("ScreenGui")
	local InstructionsLabel = Instance.new("TextButton")
	local B = Instance.new("TextBox")
	NewGui.Parent = game.StarterGui
	InstructionsLabel.Parent = NewGui
	InstructionsLabel.Size = UDim2.new(1,0,1,0)
	InstructionsLabel.MouseButton1Click:Connect(function()
		print("eyy")
	end)
end)

Only the plugin’s scripts can be executed in the studio itself, no matter if it’s in play mode or studio mode!

image
Source: Plugin | Roblox Wiki | Fandom in technical details section.

1 Like