Plugin Tutorial

Hey developers!
Today I’m going to show you how to easily create a plugin.

First off, let’s create a plugin bar.
Let’s create a new folder and place it into ‘‘ServerScriptService’’. We will call it ‘‘Plugin’’. Now we’re going to create a script and place it into the folder. We’ll call the script ‘‘PluginSetup.’’ Now let’s make some variables first.

local PluginBar = plugin:CreateToolbar("Plugin") --Replace "Plugin" with the name of your plugin.

Now let’s create a button.

local PluginBar = plugin:CreateToolbar("Plugin") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Open plugin", "Open the plugin.", "", "PluginButton")  -Button name, button description, button icon (Optional), button identifier.

You can make as many buttons as you want! Now that we have created the bar and the button(s), we can start making our actual plugin. Now you have to make a choice. Are you going to be making a DockWidgetPluginGui plugin, or a button-action plugin?
Screenshot 09-01-2021 15.17.40

A button-action plugin performs an action when you press the plugin button.

I’m going to be covering both in this tutorial. Just find the part where I cover your choice.

Button-action plugin

I’m going to be making a simple kill brick creator. Let’s make that clear by editing the plugin bar and the buttons.

local PluginBar = plugin:CreateToolbar("Killbrick creator") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Create", "Create new killbrick.", "rbxassetid://2594120598", "Killbrick creator") --Button name, button description, button icon (Optional), button identifier.

Now that we customized the plugin bar and buttons, let’s script the kill brick creator.

local PluginBar = plugin:CreateToolbar("Killbrick creator") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Killbrick creator", "Create new killbrick.", "rbxassetid://2594120598", "Create") --Button identifier, button description, button icon (Optional), button name.

PluginButton1.Click:Connect(function() --Normally you'd detect a click using "MouseButton1Click", but since we're using a plugin button, we use "Click". If the button gets clicked, we're going to activate a function. Whatever is in that function, will happen when our event gets triggered.
local KillBrick = Instance.new("Part") --With "Instance.new()", you can create a new object using a script.
local KillScript = Instance.new("Script") --With "Instance.new()", you can create a new object using a script.
KillBrick.Name = "Killbrick" --We're going to give the part a name.
KillScript.Name = "Killscript" --We're going to give the script a name.
KillBrick.Parent = game.Workspace --We're going to parent the part to the workspace, so we can see it in the world.
KillScript.Parent = KillBrick --We're going to parent the script to the part, so it effects the part.
KillBrick.Anchored = true --We're going to change a few settings to make the killbrick flawlessly work.
KillBrick.CanCollide = true --We're going to change a few settings to make the killbrick flawlessly work.
KillBrick.BrickColor = BrickColor.Red() --We'll change the color to red so the player knows it's a killbrick.
--Now we're going to change the script. But, remember this can only be used for plugins.
KillScript.Source = [[
script.Parent.Touched:Connect(function(touch)
    if touch.Parent:FindFirstChild("Humanoid") then
        touch.Parent.Humanoid.Health = 0
        end
    end)
]]
end)

Now we have a working kill brick creator plugin!

DockWidgetPluginGui plugin

I’m going to be making a simple notepad. Let’s make that clear by editing the plugin bar and the buttons.

local PluginBar = plugin:CreateToolbar("Notepad") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Notepad", "Open the notepad.", "rbxassetid://92741621", "Open") --Button identifier, button description, button icon (Optional), button name.

Now we’re going to create the DockWidgetPluginGui.

local PluginBar = plugin:CreateToolbar("Notepad") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Notepad", "Open the notepad.", "rbxassetid://92741621", "Open") --Button identifier, button description, button icon (Optional), button name.
local WidgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, false, 500, 500, 250, 250) --Standard position, enabled when Studio opens, if the widget goes back to the last position when opened again, standard horizontal size, standard vertical size, minimum horizontal size, minimum vertical size.
local Widget = plugin:CreateDockWidgetPluginGui("Notepad", WidgetInfo) --Widget identifier, widget info.

Widget.Title = "Notepad" --Let's change the title of the DockWidgetPluginGui.

Now let’s create the Gui.

local PluginBar = plugin:CreateToolbar("Notepad") --Replace "Plugin" with the name of your plugin.
local PluginButton1 = PluginBar:CreateButton("Notepad", "Open the notepad.", "rbxassetid://92741621", "Open") --Button identifier, button description, button icon (Optional), button name.
local WidgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, false, 500, 500, 250, 250) --Standard position, enabled when Studio opens, if the widget goes back to the last position when opened again, standard horizontal size, standard vertical size, minimum horizontal size, minimum vertical size.
local Widget = plugin:CreateDockWidgetPluginGui("Notepad", WidgetInfo) --Widget identifier, widget info.

Widget.Title = "Notepad" --Let's change the title of the DockWidgetPluginGui.
local NewFrame = Instance.new("Frame") --With "Instance.new()", you can create a new object using a script. This is easier so we don't have to create it in Studio.
local NewTextBox = Instance.new("TextBox") --With "Instance.new()", you can create a new object using a script. This is easier so we don't have to create it in Studio.
NewFrame.Parent = Widget --Let's parent the frame to the widget so it's visible in the widget.
NewTextBox.Parent = NewFrame --Let's parent the text-box to the frame so it's visible in the widget.
NewFrame.Size = UDim2.new(1, 0, 1, 0) --We're going to change a few settings to make the notepad flawlessly work.
NewFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255) --We're going to change a few settings to make the notepad flawlessly work.
NewFrame.BorderSizePixel = 0 --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.Size = UDim2.new(1, -20, 1, -20) --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.Position = UDim2.new(0, 10, 0, 10) --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.BackgroundColor3 = Color3.fromRGB(200, 200, 200) --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.TextColor3 = Color3.fromRGB(255, 255, 255) --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.Font = "Arial" --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.TextWrapped = true --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.TextSize = 50 --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.ClearTextOnFocus = false --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.MultiLine = true --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.TextEditable = true --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.BorderSizePixel = 0 --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.Text = "" --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.PlaceholderText = "Type here..." --We're going to change a few settings to make the notepad flawlessly work.
NewTextBox.PlaceholderColor3 = Color3.fromRGB(255, 255, 255) --We're going to change a few settings to make the notepad flawlessly work.
PluginButton1.Click:Connect(function() --Normally you'd detect a click using "MouseButton1Click", but since we're using a plugin button, we use "Click". If the button gets clicked, we're going to activate a function. Whatever is in that function, will happen when our event gets triggered.
    if Widget.Enabled == false then --If the widget is currently enabled, then we will let the script do whatever is in there.
	    Widget.Enabled = true --We are going to enable the widget. Since whe have typed an if statement before, it will only enable the widget if it's currently disabled.
    else --Since we have said "if Widget.Enabled == false then" before, "else" means "if Widget.Enabled ~= false then" in this case.
	    Widget.Enabled = false --We are going to disable the widget. Since whe have typed an if statement before, it will only disable the widget if it's currently enabled.
    end
end)

Now we have a working notepad plugin!

That’s it! I hope it helped.
Have a nice day, iamajust

21 Likes

If anyone has any feedback, don’t hesitate to tell me!

1 Like

You can just clone the gui from the folder, instead of making it with the script.

1 Like

Thanks for your contribution! As someone who does not make plugins, I might try this out later.

However, please, PLEASE format your code in lua - it makes code easier to read than black text

9 Likes

You should rather explain what each function does, and what parameters they receive, etc. Please be informative. Here’s a heads-up:

To create a toolbar (Place a example of what is an plugin toolbar, an picture would be very useful.), we use the CreateToolbar function of the plugin built-in Roblox Global. The CreateToolbar function receives a parameter (string) which will be the name displayed. Like so: plugin:CreateToolbar('TestPlugin') (Show what it’d look like by doing this.)

This makes your post very informative, since without giving as much information, the reader might / will get mislead.

Also, why is the code your formatted so weirdly? Please add spaces to it. Like this:

local Part = Instance.new('Part')
Part.Parent = workspace
Part.Name = 'Bruh'
3 Likes

This looks good and I do think you should of done this suggestion below.

2 Likes

Oh, I see now. You need to put 4 spaces before it right? Anyway, thanks for the feedback!

1 Like

That’s true. Maybe next time I can show that with images!

1 Like

Thanks! I will definitely use that in my posts.

1 Like

Thanks! I will make it without ‘‘Instance.new()’’ next time.

1 Like

I always do my GUI plugins without instance.new. It saves a lot of time and a lot of plugins use it.

2 Likes

The idea is cool, but the code is incorrectly formatted to the point where it’s unreadable. Can you reformat the code please?

1 Like

Yeah, it’s simple to fix, just paste it into Roblox Studio and format it there and then bring it here, I believe you’re using the wrong thing too? Code has a </> icon.

No, it has the ``` thing for formatting

Yes I know. I don’t write it, I select it and use the buttons up there.

Ohh. You should just put spaces on the script though, otherwise it’s unreadable.

Yes? I know I’m not the OP lol

1 Like

Thanks for the feedback! I changed it.

1 Like

Nice tutorial, this is at least more understandable than roblox wiki

1 Like

Amazing! I don’t plan on creating a plugin soon, but I really loved the explanation! Keep it up! :smile:

1 Like