Unable to locate items in plugin?

Hey so i have been trying to make a plugin to make keybinds easier but then because this is my first time, I am confused by the error.
I am unable to locate anything inside my plugin script (or just my gui).

local toolbar = plugin:CreateToolbar("Keybind Creator")
local mainBtn = toolbar:CreateButton("Create Keybinds", "Create New Keybind", "rbxassetid://1317795086")
local opened = false
--local keybindUI = script.KeybindUI
local bin = script
local gui = bin.KeybindUI:Clone()
gui.Parent = game:GetService('CoreGui')
local function onBtnClicked()
	if not opened then
		opened = true
		print('opened keybindcreator')
		gui.Enabled = true
	--insertUI = Instance.new("ScreenGui", game.CoreGui)
	--insertFrame = Instance.new("Frame",insertUI)
	--insertFrame.Size = UDim2.new(1, 0, 1, 0)
	--insertFrame.BackgroundTransparency = 0
	else if opened then
		print('closed keybindcreator')
		--insertUI:Destroy()
		gui.Enabled = false
		opened = false
	end
	end
end
mainBtn.Click:Connect(onBtnClicked)

It always comes up with:
11:18:47.564 - Keybind PluginTest.lua:3: attempt to index nil with ‘KeybindUI’
derp

I have checked other scripts and compared then but I still don’t understand why there is an error in my script.

Just gonna point out a lot of things wrong with this script:

Why do you parent the gui to CoreGui?
For gui stuff, this should be created on the client. You don’t check gui stuff like button click functions on the server because then that just makes the “servers” job pointless. (clickdetector doesnt count unless you want it to do something client sided)
What is the “plugin,” a module?

I don’t really understand you as this is my first time ever trying to make a plugin.
Also I not that good of a scripter too.

He is scripting a roblox studio plugin. This is how some of them work, though widgets are better. If you want a in depth tutorial I made one here

It looks quite helpful. Thank you.
Also, you have lots of typos in it.

Yeah probs lol. I just fixed one but there is probably a ton

How would I use a GUI though?
I would rather not use instance.new
Also because I have no idea how to edit the dock widget thing.

Well what your script did is fine but you just aren’t saving it correctly. You have to select everything(including the gui) and then save it.

Do i need to select the frames and buttons inside?

1 Like

No I guess?!?!. 30 charssssssssssssssssssssssssssssss

Well i didn’t and it still worked

1 Like