"ScreenGui is not a valid member of Script" (Plugin)

Hi devs,

I’m trying to make a plugin, and I’m getting an error, and I’m not sure how I can fix it.

This is my script:

local toolbar = plugin:CreateToolbar("Test Plugin")
local button = toolbar:CreateButton("Test Button", "This Is A Test Button", "rbxassetid://5754151192")

local pluginGui = script.ScreenGui
local guiVisible = false

button.Click:Connect(function()
	if guiVisible then
		pluginGui.Parent = script
		guiVisible = false
	else
		pluginGui.Parent = game.CoreGui
		guiVisible = true
	end
end)

pluginGui.TextButton.MouseButton1Click:Connect(function()
	if game.Selection:Get() ~= nil then
		for _, i in pairs(game.Selection:Get()) do
			local test = Instance.new("StringValue")
			test.Parent = i
		end
	else
		print("Nothing selected")
	end
end)

I have a ScreenGui inside of the script, am I supposed to put it somewhere else?

put the script inside the screen gui

also save the screengui as local plugin

1 Like