Plugin Toolbar Button sharing Toolbar with another separate Plugin

I am looking to be able to use one toolbar to host two of my plugins which are separate marketplace plugins. A good example of this is Stravant’s plugins which share the same toolbar, which can be seen below. How can I reference an existing toolbar from plugin to plugin?

image

The problem is that when I create a toolbar with the same name it will create two separate toolbars instead of one.

image

Below is the code I used for making the toolbars and button. I have tried to search everywhere for a solution but can’t find any. I thought of referencing the toolbar but can’t wrap my head around how.

local toolbar = plugin:CreateToolbar("Text Tools")

local button = toolbar:CreateButton("SignsPro", "Hide/show the Signs Widget.", "", "Signs")

local widget = plugin:CreateDockWidgetPluginGui("Signs", widgetInfo)
widget.Title = "Signs"
widget.Name = "Signs"

-- Pretend this is another plugin script.
local toolbar = plugin:CreateToolbar("Text Tools")

local button = toolbar:CreateButton("SignsFree", "Hide/show the Signs Widget.", "", "Signs Free")

local widget = plugin:CreateDockWidgetPluginGui("Signs", widgetInfo)
widget.Title = "Signs"
widget.Name = "Signs"

What if you just split the two plugins into 2 different scripts and publish them separate.

Isn’t that what I’m doing right now? I have two different published plugins which each has one script. Could you specify what you mean?

Publish This one first to roblox then publish the other half

This does not work. Same issue still persists.

If anyone know a solution or a better way to do this I would love to hear it.

Try this:
local toolbar = plugin:CreateToolbar(“Text Tools”)

local button = toolbar:CreateButton(“SignsPro”, “Hide/show the Signs Widget.”, “”, “Signs”)

local widget = plugin:CreateDockWidgetPluginGui(“Signs”, widgetInfo)
widget.Title = “Signs”
widget.Name = “Signs”

– Pretend this is another plugin script.
toolbar = plugin:FindFirstChild(“Text Tools”)
if toolbar then
local button = toolbar:CreateButton(“SignsFree”, “Hide/show the Signs Widget.”, “”, “Signs Free”)
else
plugin:CreateToolbar(“Text Tools”)
end

local widget = plugin:CreateDockWidgetPluginGui(“Signs”, widgetInfo)
widget.Title = “Signs”
widget.Name = “Signs”

toolbar isn’t a local so the other part of the script just errors. I’ve already tried something like this but it doesn’t work.

You can try this (I made it because I was facing the exact same problem)

Use a module script, require, and use functions, will let you share toolbars

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.