How do I do this?

So basically I want to make it so once you click on a button for a plugin, a UI appears on the screen(I cant figure out how to do this, ive looked at tutorials)

And also how do I tell where there mouse is? And then tell when they click? Basically just get there mouse.

Cool thanks

2 Likes

im confused on the first part.

getting the mouse’s position is fairly easy:

local mouse = game:GetService("Players").LocalPlayer:GetMouse() -- gets the local player's mouse

print(mouse.X) -- mouse's x position on the screen
print(mouse.Y) -- mouse's y position on the screen
1 Like

is it this way for getting it for a plugin? Cause I have no idea.

And for the first part, How do I make a ScreenGui Appear on the users screen?

to make it appear, parent it to coregui

1 Like

it’s easy to make a plugin, you’re gonna have to use PluginGuiService.

example code:

local PluginGuiService = game:GetService("PluginGuiService")
local button = script.Button -- change it to the button you need to trigger

local showUI = function()
    local screenGui = PluginGuiService:CreateDockWidgetPluginGui("YOUR PLUGIN'S NAME ;)", DockWidgetPluginGuiInfo.new(
        Enum.InitialDockState.Float, 
        true, 
        true,
        300, -- initial width
        200, -- initial height
        200, -- minimum width
        100 -- minimum height
    ))

    local frame = Instance.new("Frame") -- example
    frame.Parent = screenGui
end

button.MouseButton1Click:Connect(showUI)
1 Like

This appears to not be an option, is this normal?

Like in the list of services its not there

it is an option, but you can only access it by the following code:

local pluginGuiService = game:GetService("CoreGui"):FindFirstChild("PluginGuiService")

because the PluginGuiService does not directly retrieve from the game

1 Like

CoreGui is also not in there, is this normal? I have a feeling it probably is

1 Like

OOP- that was a mistake. i meant StarterGui and not CoreGui

2 Likes

An error occurred,

 20:57:54.130  user_Insert.rbxmx.Insert.Script:17: attempt to index nil with 'CreateDockWidgetPluginGui'  -  Edit - Script:17
  20:57:54.130  Stack Begin  -  Studio
  20:57:54.130  Script 'user_Insert.rbxmx.Insert.Script', Line 17  -  Studio
  20:57:54.130  Script 'user_Insert.rbxmx.Insert.Script', Line 35  -  Studio
  20:57:54.131  Stack End  -  Studio

Code:

-- get the toolbar
local toolbar = plugin:CreateToolbar('Insert')


local button = toolbar:CreateButton(
	"Insert Onjects", -- text that appears below button
	'Contains templates, objects, vehicles, etc! Then you can easily insert them!', -- Text that appears if you hover the mouse on button
	"rbxassetid://13814749560" -- button Icon
)



local pgs = game:GetService('StarterGui'):FindFirstChild('PluginGuiService')


local showUI = function()
	local screenGui = pgs:CreateDockWidgetPluginGui("YOUR PLUGIN'S NAME ;)", DockWidgetPluginGuiInfo.new(
		Enum.InitialDockState.Float, 
		true, 
		true,
		300, -- initial width
		200, -- initial height
		200, -- minimum width
		100 -- minimum height
		))

	local frame = script.Parent:FindFirstChild('Frame'):Clone() -- example
	frame.Parent = screenGui

end
	


button.Click:Connect(function()
	showUI()
end)

Why are you using StarterGui rather than CoreGui?

1 Like

CoreGui isnt an option to begin with so I have no idea

Some services don’t appear, just replace StarterGui with CoreGui.

Or if that doesn’t work do what it originally was PluginGuiService.

This doesnt work, It says that CreateDockWidgetPluginGui is not a valid member of that service.

Same with CoreGui.

try replacing the psg with this:

local manager = game:GetService("PluginManager")
local plugin = manager:CreatePlugin()
local toolbar = plugin:CreateToolbar("plugin example")

plugin:Activate(true)

and replace the psg in this line with the plugin variable

This also isnt a thing on the list. Is this normal?