Skip to content
Zalaxis edited this page Jun 15, 2023 · 2 revisions

Code :

-- Define constants
local PLUGIN_NAME = "MyPlugin"
local TOOLBAR_BUTTON_NAME = "OpenPluginButton" -- Name of Plugin
local PLUGIN_MENU_ITEM_NAME = "Open Plugin"
local PLUGIN_ICON_ID = "rbxassetid://8073107221" -- Icon

-- Define variables
local toolbar = plugin:CreateToolbar("MyPluginToolbar") -- Bottom Text
local toolbarButton = toolbar:CreateButton(TOOLBAR_BUTTON_NAME, "Open Plugin", PLUGIN_ICON_ID)
local pluginMenu = plugin:CreatePluginMenu(PLUGIN_MENU_ITEM_NAME)

-- Define UI variables
local pluginWidget = plugin:CreateDockWidgetPluginGui(PLUGIN_NAME, DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, false, false, 300, 200, 250, 150))
local mainFrame = Instance.new("Frame") -- Interface
mainFrame.Size = UDim2.new(1, 0, 1, 0)
mainFrame.BackgroundColor3 = Color3.new(0.8, 0.8, 0.8)
mainFrame.Parent = pluginWidget

-- Define functions
local function OpenPlugin()
	pluginWidget.Enabled = not pluginWidget.Enabled
	print("MyPlugin opened!")
end

-- Connect the toolbar button click event
toolbarButton.Click:Connect(function()
	OpenPlugin()
end)

-- Connect the plugin menu item click event
pluginMenu:AddAction(plugin:GetMouse(), PLUGIN_MENU_ITEM_NAME)
pluginMenu.Triggered:Connect(function()
	OpenPlugin()
end)

Description

This script creates a plugin in Roblox Studio. It performs the following tasks:

  • Defines constants, including the plugin name, toolbar button name, menu item name, and icon ID.

  • Creates a toolbar with the name "MyPluginToolbar".

  • Creates a toolbar button with the specified name, caption, and icon.

  • Creates a plugin menu with the specified name.

  • Creates a dock widget plugin GUI with the plugin name and specific dimensions.

  • Creates a frame within the plugin widget and sets its size and background color.

  • Defines a function named OpenPlugin that toggles the visibility of the plugin widget and prints a message when the plugin is opened.

  • Connects the Click event of the toolbar button to the OpenPlugin function.

  • Connects the Triggered event of the plugin menu item to the OpenPlugin function.

  • By running this script, a plugin will be created in Roblox Studio with a toolbar button and a menu item. Clicking either of them will toggle the visibility of the plugin widget and print a message indicating that the plugin has been opened.

Please note that this is a basic overview of the script's functionality. Additional details and explanations can be provided as needed.

Clone this wiki locally