Plugin Creation Help

Recently when I finished a commission of a building tool, I had to make it a plugin and went through the steps of making it a folder and added the necessary scripts to make it work as a plugin, when I sent it to the buyer, the plugin did not work on their system and I did further testing to see if it worked on new studio places for me, on the new studio instance the plugin did not work for me. After all this I did some testing and deleted the plugin’s files on the place it worked originally and it still worked.
Some further info:
The plugin works when I playtest the game (only pressing the play button works, run does not work) and any new plugins I create from that old file still work but only on that one place.
The plugin is all saved in a folder which I then save using Explorer > Save as local plugin
The handler of the building system itself is a localscript

Here is the code to open the plugin:

local toolbar = plugin:CreateToolbar(“Plugin”)
local button = toolbar:CreateButton(“Open Test Plugin”, “Click to toggle the plugin UI”, “rbxassetid://13761772453”)

local PluginUI = script.Parent.Parent:WaitForChild(“ScreenGui”)

local function togglePluginUI()
if PluginUI then
PluginUI.Parent = game:GetService(“CoreGui”)
PluginUI.Enabled = not PluginUI.Enabled
end
end

button.Click:Connect(togglePluginUI)

Any help is appreciated

How does the hierarchy of your plugin look like? Also, would you like the button to act as a toggle for the Gui?

image
Here is my hierarchy,
Yeah the button should toggle the gui but I did have a close button earlier, this script is just a few hours of trying to fix it.

I recommend placing the server Script that handles the logic for the plugin directly inside of the BuildingPlugin Folder instead of the ScreenGui. At the moment this is how your script should essentially look like:

local CoreGui = game:GetService("CoreGui")

local pluginToolbar = plugin:CreateToolbar("Plugin")

local pluginToolbarButton = pluginToolbar:CreateButton(
	"Open Test Plugin",
	"Click to toggle the plugin UI",
	"rbxassetid://13761772453"
)

local pluginUI = script.Parent
local buildingPlugin = pluginUI.Parent

local active = false

local function onClick()
	if active then
		pluginUI.Parent = buildingPlugin

		active = false
	else
		pluginUI.Parent = CoreGui

		active = true
	end

	pluginToolbarButton:SetActive(active)
end

pluginToolbarButton.Click:Connect(onClick)

Let’s say I wanted to rewrite the plugin to simplify the placing system with the mouse i.e making it only work outside of playtest mode, would I then need to place all of this in a single server script or am I able to handle it with a localscript and a server script at the same time?