How to use a GUI object in a plugin?

Is it possible to create a plugin containing Gui that can be in some way used as a Plugin Gui, or in other words actively be used by someone in Studio without going into Play mode?

Or is the only option to create a Dock widget plugin and parent instances such as text-boxes to to that?

Are you asking if gui objects can be used in the viewport from a plugin? if so, then yes you can, by placing them in the CoreGui. Or do i not understand your question?

I believe you do not.

Yes, I am aware you can simply clone Gui to a Player , but my question was that could we use Gui objects themselves while in Studio and not in test mode through the means of using a plugin?

My goal is to create Gui that opens once a plugin toolbar button is clicked, and let users input data and use Gui components such as text buttons, while not in test mode.

Or are you saying that if I clone the Gui into CoreGui through a plugin, then players will be able to use it as I intend?

@OnlyJaycbee

Or is my only other option to create a dock widget Gui and just parent other Gui objects to it?

Putting Gui in the Coregui from a plugin, will allow buttons and such (pretty much any Gui object) to work anywhere in the viewport without having to use test mode or anything. As far as i know that is the only other option.

well it just goes in the viewport and I can see it, but I cannot click text buttons to any effect (as I would have if I had kept them in StarterGui in test mode that is).

how do you have it set up? it works for me when i just have a ScreenGui and textbutton in my plugin and parent it to the Coregui (when the plugin is first ran)

The text button does not detect any input.

like this :

image

I used the model because of the strange behavior that saves scripts as .Lua, whilst only rbxmx works , so ignore that.

My code in the script :

local toolbar = plugin:CreateToolbar("tools")


    local newScriptButton = toolbar:CreateButton("open", "abc", "rbxassetid://4458901886")
    local core =  game:GetService("CoreGui") 
    local gui = script.gui
    
 
	  newScriptButton.Click:Connect(function() 

  if not core:FindFirstChild("gui") then 
     
       local clone = gui:Clone()
       clone.Parent = core

   return end
 
       core.gui:Destroy()
    
     
  end)
1 Like

Sorry for the late reply, but i’m not sure why it’s not working for you atm. Here’s a place file that has a model in the ServerScriptService that when saved as a local plugin it shows a textbutton that should be able to clicked and print text in the output.

PluginTest.rbxl (21.0 KB)

1 Like

I meant as in a plugin with a button in the toolbar that then when clicked, opens the gui.

@OnlyJaycbee Ok Can anyone tell me what I am doing wrong here?

What’s supposed to happen is that when you click the button in the plugin toolbar, a Gui is shown, when clicked again it is removed.

That part happens, but then clicking a button in the Gui does not print anything.

I know there is something I’m doing really wrong and I want to know.

Place file : PluginTest (1).rbxl (21.5 KB)

1 Like

i tested your set-up and like you said it doesn’t work! , The (very likely) reason i believe it isn’t working is because scripts can’t actually run in the Coregui! meaning that when a button is cloned to the coregui the scripts in it or whatever don’t actually run and thus no event is truly connected to your button. The way to fix this would be to do all code and connections from within the plugin instead (where things can run).


So, with your specific example, connecting the MouseButton1Click event inside the plugin script made everthing work as expected.

Hmm… this seems to work for me (at least MouseEnter), you’re connecting the events after everything has been cloned or moved to the coregui right?

Doing this seemed to work using the “old set-up”:

local toolbar = plugin:CreateToolbar("tools")


local newScriptButton = toolbar:CreateButton("open", "abc", "rbxassetid://4458901886")
local core =  game:GetService("CoreGui") 
local gui = script.gui
    
 
newScriptButton.Click:Connect(function() 

	if not core:FindFirstChild("gui") then 
     
		local clone = gui:Clone()
		clone.Parent = core
		clone.TextButton.MouseEnter:Connect(function()
			print("Yay")
		end)
		return
	end
 
	core.gui:Destroy()
    
end)

I used different modules and handled everything from the plugin script, worked.

2 Likes