This week I learned how to use Plugin GUIs/Lua Widgets! They’re super awesome and I love them, so here’s another tutorial on how to use them. Feel free to ask questions, as always.
I’ve tried this, and I sadly can’t get it to work to have at least my textbutton show up. The window opens, and that’s it:
local interface = plugin:CreateDockWidgetPluginGui(
"Install BloxTech",
DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
true,
400,
500,
400,
500
)
)
interface.Title = "Install BloxTech"
script.TextButton:Clone().Parent = interface
script:WaitForChild("TextButton").Parent = interface
Structure:
Result:
Thanks in advance for the help!
I’m honestly not sure why it wouldn’t work, although I’ll note that it seems like you’re putting two of the same object in the interface. Is that intentional?
script.TextButton:Clone().Parent = interface --clone the textbutton to the widget
script:WaitForChild("TextButton").Parent = interface --move the original to the widget
Also, is there any output?
I have a similar problem. The plugin shows up white too. I get this error:
Plugin.lua:14: attempt to index global ‘script’ (a nil value)
This is the code:
Looks like it can’t reference itself, aka the script, for some reson.
That’s a pretty odd bug. For now, I’ve figured out that you can work around the issue by encasing the script inside of a folder or some other container and then publishing the container as the plugin:
Also, for future reference, you can paste code blocks in a readable format with three tick marks (`), followed by “lua” (the programming language), then your code, and then three more tick marks:
--this is properly formatted code
local var="hi"
print(var)
Thanks for the reply. However, your solution did not work
When I right click the folder and click “Save as Local Plugin”, the following output is being sent:
Plugin successfully saved as C:/Users/MEEEE/AppData/Local/Roblox/Plugins/Plugin.rbxmx
Refreshing plugin...
But when I go to that directory, no file is added.
I also tried changing the saving directory and it did not work…
I tried exporting a script as a plugin from the same game and it worked fine.
That’s very odd, and definitely not intended behavior… you might want to file a bug report.
I’m a little late to the party but this is one of the only good tutorials I can find on making widget plugins. Thanks so much for this! It really helped!
I tried this a little differently and got it to work:
Workspace:
Script contents:
local dockWidget = plugin:CreateDockWidgetPluginGui(
"Install BloxTech",
DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
true,
400,
500,
400,
500
)
)
local model = script.Parent -- My Plugin Model
local gui = model.ScreenGui
gui:WaitForChild("TextButton")
local textButton = gui.TextButton
dockWidget.Title = "Install BloxTech"
textButton:Clone().Parent = dockWidget
Make sure that you save the model containing both your script and your GUI elements as the RBXM. There’s a bug that I’m fixing in Studio where when you right click and save a script as a plugin that said script is saved as Lua and not a Model. This only works if your script has no dependencies on GUI elements. The workaround is to use a Model or other container above your script and save it as a plugin from that. I renamed mine “My Plugin Model” for clarity.
Also, don’t take my code above as example level code - I’m just following the pattern I see you using and mildly renaming stuff trying for clarity.
That helped, thanks a lot!
I managed to export the plugin by chosing a directory outside of my user. Perhaps that’s because my user’s name has cyrillic letters in it, there were a few programs that got messed up because of that, but just saving the plugin into a separate directory right in the drive worked fine. Thanks for your guide by the way, it was extremely helpful and, perhaps, the simplest one out there
Hi there !
I have a question : I would like to make the GUI appear when you click the button in a toolbar but I dont know how to change the DockWidgetPluginGui properties.
Thanks in advance,
Fabrice
I don’t know if you are still having problems with this, but I just made a plugin like this and it worked for me. The fix was to highlight everything inside of the script as well as the script itself when publishing.