How To Make Plugins
Prerequisites (What you need)
- A decent knowledge of scripting in Lua
- Text editing program (such as Notepad)
- Roblox Studio
The plugins folder
A plugin isn't like a normal script. It's saved onto your computer! To get to where you save plugins, you'll need to:
- Go to Roblox Studio
- Click Tools->View Plugins Folder
- Now, a folder browser should pop up. On windows, it should be something along the lines of:
C:\Users\YourUsernameOnYourComputer\AppData\Local\Roblox\plugins Plugins don't delete when roblox updates, since they're stored seperately to actual roblox files which get updated.
Creating the plugin folder and getting an icon
In your plugins folder, right click and click 'New' and click 'Folder'.
Name it 'Hello World Plugin'
Now, we need some files. First-off, you might want to download an icon set. This link is the set that Roblox uses for most of it's icons- FamFamFam's Silk icon set. It's a great icon set, check it out here: [Silk icon set by FamFamFam]
Once you find a nice icon you like (Or make your own- Generally 16x16 png files.) right click it and click copy, then go to you 'Hello World Plugin' folder, and paste it.
Now you've got an icon.
Creating the plugin scripts
This is the part where you need your leet scripting knowledge.
Open up Notepad or your favourite text-editing software ([Notepad++ is great for programming/scripting!])
Now, plugin's API is as follows (Not complete reference, these are just the things you need to make a basic plugin!):
local PluginManagerObject = PluginManager() Returns the plugin manager service.
local Plugin = PluginManagerObject:CreatePlugin() Returns a plugin (You can use PluginManager():CreatePlugin() if you want shorter code)
local Toolbar = Plugin:CreateToolbar("Hello World Plugin Toolbar") This returns a toolbar. It's empty right now.
local Button = Toolbar:CreateButton("Print Hello World", "Click this button to print Hello World!", "IconName.png") The first argument, 'Print Hello World' is the text to appear next to the icon. You can leave this blank if the icon is descriptive enough. The second is what text appears when you hover on the caption for a while, and the third is the icon. Make sure you change it to your icon's name!
Button.Click:connect(function) Finally we get onto something we're used to! Events! It works like a normal roblox event, so we can do this: Button.Click:connect(function() print("Hello, World!") end)
Altogether now!
By combining all the code we've done so far, we have a functional plugin!
local PluginManagerObject = PluginManager() local Plugin = PluginManagerObject:CreatePlugin() local Toolbar = Plugin:CreateToolbar("Hello World Plugin Toolbar") local Button = Toolbar:CreateButton("Print Hello World", "Click this button to print Hello World!", "IconName.png") Button.Click:connect(function() print("Hello, World!") end)
Yay! Now save it to wherever you like (I recommend 'My Documents'), and, if you're using Notepad, make sure this is what the save dialog looks like:
Notice the 'All Files' bit, and we added '.lua' on the end.
Save it, and open the folder where you saved it. Now drag the file into the 'Hello World Plugin' folder!
Now let's view your plugin in action!
Now that your plugin is done, we can look at it!
Launch roblox studio and launch any place, and you should see a shiny new button on your toolbar (Or an error in your output. D:)
Click the button, and 'Hello, World!' should appear in the output!
Huzzah! You made a plugin! Now you can adjust it! But you still don't know all there is to know about plugins!
- Check out the Selection service to manipulate what the plugin user has selected (Great for CFrame plugins!)
- Check out the Full plugin API to view more cool plugin features!