Mouse is Clicking through Plugin and getting Object behind it

I have a plugin that I select a game Object in Workspace, then I click my plugin button and it adds in some stuff. That all works fine and dandy, except on this one odd occasion.

I have an Error that pops up if you have nothing selected, and one that pops up if you aren’t selecting a UI Element.

So I am using game.Selection:Get()[1] and if I have nothing selected, and click my Plugin Button, it’ll error like it should, but then when I select a UI Element, and then click the button, it basically clicks through the Plugin and selects the part behind where the plugin covers the screen.

I don’t know what to try to do to fix it because I’ve honestly never seen this happen in my life.

Any help would be much appreciated. Thanks.

Code
--------[VARIABLES]--------
local Toolbar = plugin:CreateToolbar("UI Tool")
local ToolbarButton = Toolbar:CreateButton("Roundify", "Give Square UIs Rounded Corners", "rbxassetid://1507949215")
 
local MainGui = script.RoundifyGui:Clone()
MainGui.Parent = game:GetService("CoreGui")

local Error = MainGui:WaitForChild("Error")

local Selections = MainGui:WaitForChild("Holder"):WaitForChild("ThicknessSelection"):GetChildren()
local ThicknessSize = "12px"
local SelectionSize = MainGui:WaitForChild("Holder"):WaitForChild("SelectionSize")

--------[FUNCTIONS]--------
ToolbarButton.Click:Connect(function()
	MainGui.Enabled = not MainGui.Enabled
end)

MainGui:WaitForChild("Holder"):WaitForChild("RoundifyHolder"):WaitForChild("Roundify").MouseButton1Click:Connect(function()
	local Selection = game.Selection:Get()[1]
	local Roundify = script:FindFirstChild("Roundify" .. "_".. ThicknessSize)
	print(Selection)
	if Selection == nil then
		Error.Text = "Error: Nothing Selected. Please Select a UI Element"
		wait(2)
		Error.Text = ""
		return
	end
	if Selection:IsA("Frame") or Selection:IsA("ScrollingFrame") or Selection:IsA("TextButton") or Selection:IsA("TextBox") or Selection:IsA("TextLabel") or Selection:IsA("ImageLabel") or Selection:IsA("ImageButton") then
	    print(ThicknessSize)
	    local NewRoundify = Roundify:Clone()
	    NewRoundify.Parent = Selection
	    for _, Element in pairs(NewRoundify:GetChildren()) do
		    Element.ImageColor3 = Selection.BackgroundColor3
		    Element.ImageTransparency = Selection.BackgroundTransparency
	    end
	
	    game.Selection:Set({NewRoundify})
	    return
	else 
		Error.Text = "Error: " .. Selection.Name .. " Is not a UI Element"
		wait(2)
		Error.Text = ""
	end
end)

for _, Selection in pairs(Selections) do
	Selection.MouseButton1Click:Connect(function()
		ThicknessSize = Selection.Name
		SelectionSize.Text = "Current Size: " .. ThicknessSize
		print(ThicknessSize)
	end)
end
1 Like

I think It’s a bug with the new UI Editor, might want to switch to studio windows for plugins instead of gui

1 Like

I’ve started getting this issue again with my plugin GUIs, when I select something in explorer and click my plugin GUI, my click deselects the explorer items and isn’t detected properly.

How do I do that? I’ve bee trying to find out. I am using tktech’s Class Change Plugin and it does not allow windowed mode.