Med Written By KrakenLordGames

Making a Working Plugin Created on: 17-05-2020

This will teach you how to make a plugin that makes a new script in studio!

>If your having trouble, or having problems on what to do, please comment on this! >Note that other players may have some trouble, because ROBLOX is always updating.

Introduction

You see, everyone uses plugins. But what if you can make a plugin? That is possible. Ill be teaching that today!

What is a plugin, anyways?

A plugin is the main object responsible for creating basic studio widgets. It is a custom add-on to Studio which adds new behavior and features that are not normally included.

Both the Animation Editor and Terrain Tools were originally developed as plugins. There are also many plugins made by the Roblox community that you can use to help make games and experiences.

You can find new plugins in the Studio Toolbox. Once installed, you can manage/update plugins through the Manage Plugins button in the Plugins tab.

Now what you know wha a plugin is, lets get to how you make one!

Starting the plugin.

Now, we need to make the plugin!

There are three main stuff we need to know about s plugin though.

Update (Section A) Downloads the latest version/inprovement of that plugin.

Active (Section B) Turn on/off the setting if the plugin is active.

Details/Remove (Section C) Either view the details or remove the plugin.

Now that we know those, make a script in the ServerScriptService and keep the following:

print("Hello world!")

If you have the "return module" function, then you have a ModuleScript. Insert a Normal "Script".

After that, right click the script and press "Save as Local Plugin." This will save the plugin.

Open the Output, and you should get this the "Hello world" in there. If not, make sure you've inserted a normal script. If it still will not work, check your Studio version. Some peopple have outdated studios and this is why it willl never work.

Adding the Toolbar Button

Now, you've tested your plugin. But it's missing something. What? A toolbar button! Almost all plugins have this, and it helps the player know they have that plugin.

For this, you’ll need to call the Plugin:CreateToolbar() and PluginToolbar:CreateButton() functions.

local toolbar = plugin:CreateToolbar("Custom Script Tools")
 
local newScriptButton = toolbar:CreateButton("Create Empty Script", "Create an empty script", "rbxassetid://4458901886") 

-- Remeber to change the ID also if you want.

It does not do anything, so we need to make it do something. Add this to the code:

local function onNewScriptButtonClicked()
	local newScript = Instance.new("Script")
	newScript.Source = ""
	newScript.Parent = game:GetService("ServerScriptService") 
end
newScriptButton.Click:Connect(onNewScriptButtonClicked)

-- The "newScript.Parent" function will send that script where it goes. You can change that.

Undo it, Redo it!

Undo and redo in Studio are managed by waypoints in ChangeHistoryService. After every action in Studio, such as the user dragging a part or inserting a new object, Studio automatically adds a waypoint. When you undo an action, Studio goes back to its last waypoint and undoes everything that happened afterward.

The catch with plugins is that they do not add new waypoints by default. If a plugin makes a change to a place and the user activates Undo, Studio will undo the last non-plugin action and all of the things the plugin did.

To make sure Studio can cleanly undo a plugin’s action:

Add a local variable for ChangeHistoryService called ChangeHistoryService. Call SetWaypoint() in the final line of the onNewScriptButtonClicked() function:

local ChangeHistoryService = game:GetService("ChangeHistoryService")
 
-- Create a new toolbar section titled "Custom Script Tools"
local toolbar = plugin:CreateToolbar("Custom Script Tools")
 
-- Add a toolbar button named "Create Empty Script"
local newScriptButton = toolbar:CreateButton("Create Empty Script", "Create an empty script", "rbxassetid://4458901886")
 
local function onNewScriptButtonClicked()
	local newScript = Instance.new("Script")
	newScript.Source = ""
	newScript.Parent = game:GetService("ServerScriptService")
	ChangeHistoryService:SetWaypoint("Added new empty script")
end
newScriptButton.Click:Connect(onNewScriptButtonClicked)

Publishing Plugins to ROBLOX

All you gotta do now is right click on the plugin again, and click publish as plugin! I reccomened if your doing a icon for it, use a 512x512 sized image.

Finished!

I hope you like this tutorial. I really enjoy making people smile every day, no matter what. Thanks!

> Please dont be scared or thinking your question is dumb, please comment if you need help! >Thanks for viewing!

Med Written By KrakenLordGames

See KrakenLordGames's profile on Roblox

Discussion