Am I able to use InsertService to create a UI in a plugin instead of manually scripting it myself?

Hello!

Title basically. Am I able to create a UI in studio that functions, and then just export it as a model, and then import it using InsertService instead of just creating buttons and scripting those buttons via script? I am using a DockWidget.

2 Likes

You can just parent the ScreenGui to whatever instance you’re uploading as a plugin / saving as a local plugin. I usually have each plugin be a Folder, with a Main script and a ScreenGui inside if it’s needed. The script can then just clone the GUI and put it in CoreGui or clone the children into a DockWidget.

E.g. here’s the instance hiearchy:

image

Here’s the code for putting the GUI in a DockWidget.

local pluginGui = game.StarterGui:FindFirstChild("TEd_GUI") or pluginFolder:WaitForChild("TEd_GUI", 1000)

assert(pluginGui ~= nil, "Could't find TEd_GUI, please report this to the plugin creator.")
for _, c in pairs(pluginGui:GetChildren()) do
  local c = c:Clone()
  c.Parent = widget
end

It looks first in StarterGui so that I don’t have to move it between the Folder and StarterGui when I switch between building the GUI and testing stuff.

EDIT: Oh, and a huge time saver is saving plugins locally instead of uploading every time, because the upload process is just incredibly slow when you’re doing several small changes per minute. Just right click anything to save it as a plugin. I bound a keyboard shortcut to it as well:

image

1 Like