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?
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