Making a basic plugin - Tutorial

First tutorial, yay! Please make sure to point out any typographical errors

Alright, so you want to make a plugin. Either for personal or public use, plugins are a very useful thing.

Alright, but why should I make a plugin?

They’re incredibly useful for assisting development. From tree generation to building tools, they help in automating various tasks and speeding up development time. Today we’re going to be making a part creator. I’m also going to try to keep it beginner friendly, so if you’re new to studio don’t worry.


Preparation

First of all, you have to create a script. This script is the core of your plugin. Personally, I placed it into ServerStorage and named it “PartCreator”. Be careful what you name it, as that will be the name of the plugin.
image

Now, right click on the plugin and select “Save as Local Plugin”.
image
This will create a plugin locally, so you can test it before publishing to roblox.


Code
As mentioned above, we’re going to be making a part adder this tutorial. As you can notice however, there’s nothing in the toolbar; we need to create the button via a script.

local toolbar = plugin:CreateToolbar("Part Adder") -- create a toolbar

local CreatePartButton = toolbar:CreateButton("Create a part!","Create a part.","") -- First Parameter: ToolTip, Second parameter: ToolTip. Third parameter: Icon id.

Now save as local plugin again. If this comes up, don’t worry. You’re just updating the source.
image
Now, if you do everything correctly the following should come up:
image
Congratulations! You’ve created your first plugin.


Making the button work
First, we have to create the function that will actually add the part. Here’s an example, you can play around with the properties.

local function CreatePart() -- Creating a new function.
	local part = Instance.new("Part") -- creating the part
	part.Parent = workspace -- setting the parent
	part.Size = Vector3.new(3,3,3) -- setting the size
end

Now we just connect the function, and we’re done!

CreatePartButton.Click:Connect(CreatePart) -- Connecting the function
Full code
-- PartAdder

local toolbar = plugin:CreateToolbar("Part Adder") -- create a toolbar

local CreatePartButton = toolbar:CreateButton("Create a part!","Create a part.","") -- First Parameter: ToolTip, Second parameter: ToolTip. Third parameter: Icon id.


local function CreatePart() -- Creating a new function.
	local part = Instance.new("Part") -- creating the part
	part.Parent = workspace -- setting the parent
	part.Size = Vector3.new(3,3,3) -- setting the size
end


CreatePartButton.Click:Connect(CreatePart) -- Connecting the function

Now, if you wish to, you can publish to plugin and set Sale to True, so other people can buy it.


Now press submit, and that’s it!

Coding challenge: create a plugin that anchors every part in workspace. I recommend researching ipairs if you’re stuck on this one.

Thanks for reading!

19 Likes

Great tutorial, this is really helpful!

1 Like

I made a plugin that inserts script.

Hello! But could you tell me what is ipairs (I started scripting like a week ago and I try learning when I am bored)