PluginMenu

Show Deprecated
Not Creatable
Not Replicated

A context menu that can be shown in Studio. It displays a list of PluginActions and supports submenus.

PluginMenus must be created using the Plugin:CreatePluginMenu() function in order to work as expected.

See also:

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)

Summary

Properties

The icon to be displayed when used as a sub menu.

NOT REPLICATED

The text to be displayed when used as a sub menu.

NOT REPLICATED

Events

Methods

AddAction(action: Instance): void  

Adds the given action to the menu.

AddMenu(menu: Instance): void  

Adds the given menu as a separator.

AddNewAction(actionId: string, text: string, icon: string): Instance  

Creates a temporary action that is hidden from Studio's customize shortcuts window.

AddSeparator(): void  

Adds a separator between items in the menu.

Clear(): void  

Clears the menu.

ShowAsync(): Instance  YIELDS

Shows the menu at the mouse cursor. Yields until either an item is selected or the menu is closed.

Properties

Icon

Not Replicated

This property determines the icon to be displayed when used as a sub menu. It defaults to an empty string "".

Title

Not Replicated

This property determines the text to be displayed when a PluginMenu is used as a sub menu. It defaults to an empty string "".

Events

Methods

AddAction

void
Plugin Security

Adds the given action to the menu.

Parameters

action: Instance

The action to add.


Returns

void

No return.

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)

AddMenu

void
Plugin Security

Adds the given menu as a separator.

Parameters

menu: Instance

The menu to add as a sub menu. Uses its PluginMenu.Title and PluginMenu.Icon to display.


Returns

void

No return.

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)

AddNewAction

Plugin Security

Creates a temporary action that is hidden from Studio's customize shortcuts window.

Parameters

actionId: string

Must be a unique string that identifies this PluginAction from others.

text: string

The text to be displayed.

icon: string

The icon to be displayed.

Default Value: ""

Returns

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)

AddSeparator

void
Plugin Security

Adds a separator between items in the menu.


Returns

void

No return.

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)

Clear

void
Plugin Security

Clears the menu.


Returns

void

ShowAsync

Yields
Plugin Security

Shows the menu at the mouse cursor. It yields until either an item is selected or the menu is closed. The selected action fires its PluginAction.Triggered event.


Returns

The PluginAction item that was selected or nil.

Code Samples

Creating a PluginMenu and PluginMenuAction

1-- This code can be pasted into the command bar, but only once.
2
3local plugin = plugin or getfenv().PluginManager():CreatePlugin()
4plugin.Name = "Plugin"
5plugin.Parent = workspace
6
7local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
8pluginMenu.Name = "Test Menu"
9
10pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
11pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
12
13local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
14subMenu.Name = "Sub Menu"
15
16subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
17subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
18
19pluginMenu:AddMenu(subMenu)
20pluginMenu:AddSeparator()
21
22pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
23
24local toggle = Instance.new("BoolValue")
25toggle.Name = "TogglePluginMenu"
26toggle.Parent = workspace
27
28local function onToggled()
29 if toggle.Value then
30 toggle.Value = false
31
32 local selectedAction = pluginMenu:ShowAsync()
33 if selectedAction then
34 print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
35 else
36 print("User did not select an action!")
37 end
38 end
39end
40
41toggle.Changed:Connect(onToggled)