plugin:GetMouse() not working?

I’m currently developing a Plugin and i ran into this problem that the i cannot get the Plugin Mouse using plugin:GetMouse(), also i read the documentation of PluginMouse and i needed to activate the plugin by typing plugin:Activate(true) and it still doesnt work…

plugin:Activate(true)

local PluginMouse = plugin:GetMouse()

ToolsFrame.LinkLanes:GetPropertyChangedSignal("Visible"):Connect(function()
	if ToolsFrame.LinkLanes.Visible then else return end
	if Options._Development["Linking Lanes"] then return end
	
	Options._Development["Linking Lanes"] = true
	
	print("linking") -- actually prints when LinkLanes frame gets visible

	local SelectLane = ToolsFrame.LinkLanes.Frame.SelectLane
	local Cancel = ToolsFrame.LinkLanes.Frame.Cancel
	
	local FirstClick = nil
	FirstClick = PluginMouse.Button1Down:Connect(function()
			local Target = PluginMouse.Target
			
			print(Target) -- doesn't print
			
			if Target then else return end
			if Target.Parent.Parent == workspace:FindFirstChild("Nodes") then else return end
			
			print("Is a node lane")
		end)
end)

Also wrote this one if you think the first one is too confusing:

plugin:Activate(true)

local PluginMouse = plugin:GetMouse()

PluginMouse.Button1Down:Connect(function()
	print("Button down") -- doesn't print
end)

also i just noticed it does work while the plugin loads and i there is no tool selected (Select, Move, Scale, Rotate)

1 Like

Did you save it as a LocalPlugin? Cause this right here 100% works.

1 Like

i saved RoadBuilder folder as a Local Plugin
image

does it only work as a published plugin? cause i really wanted it to work at both types

1 Like

so I can’t remember exactly but plugin:GetMouse() doesn’t work on everything.
For example, try clicking inside the game’s viewport and see if it works then try clicking in a different frame like Explorer, Properties, etc…
I think it works in the game viewport but not in any other frame

1 Like

it is suposed to get the mouse target and it sometimes works sometimes not

1 Like

The best way of using plugin:Activate(true) is running it when you hover over your ui

The reason your mouse stops working is that when you do any action (Selecting Tools, Selecting objects, etc…) in roblox studio it’ll automatically deactive your plugin mouse.

When i’ve accounted all of those possibilities this is the best usage i’ve found:
image

Basically there must be an activaton/focus condition