plugin:GetMouse() working only once

Hi so I was making a plugin to change surface types of parts

The issue is that it only works once, then when I select something, the mouse stops working (no events are fired after, etc.).

local mouse = plugin:GetMouse()

...

mouse.Button1Down:Connect(function()
	if not enabled then return end
	if not mouse.Target then return end
	if not mouse.Target:IsA("Part") then return end
	
	print(mouse.Target)
	
	if mouse.TargetSurface == Enum.NormalId.Top then -- dumb code but idc
		mouse.Target.TopSurface = selectedSurface
	elseif mouse.TargetSurface == Enum.NormalId.Bottom then
		mouse.Target.BottomSurface = selectedSurface
	elseif mouse.TargetSurface == Enum.NormalId.Back then
		mouse.Target.BackSurface = selectedSurface
	elseif mouse.TargetSurface == Enum.NormalId.Front then
		mouse.Target.FrontSurface = selectedSurface
	elseif mouse.TargetSurface == Enum.NormalId.Right then
		mouse.Target.RightSurface = selectedSurface
	elseif mouse.TargetSurface ==Enum.NormalId.Left then
		mouse.Target.LeftSurface = selectedSurface
	end
end)

...

local function addSetButton(surfaceType: Enum.SurfaceType)
	setFrame.CanvasSize = UDim2.new(0,0,0, setFrame:WaitForChild("UIListLayout").AbsoluteContentSize.Y)

	local newButton = setButton:Clone()
	newButton.Parent = setFrame
	newButton.Text = surfaceType.Name

	newButton.MouseButton1Click:Connect(function()
		enabled = true
		
		for _, v in pairs(setFrame:GetChildren()) do
			if v:IsA("GuiObject") then
				v.BackgroundColor3 = Color3.fromRGB(55, 55, 55)
				v.bottom.BackgroundColor3 = Color3.fromRGB(30,30,30)
			end
		end
		
		newButton.BackgroundColor3 = Color3.fromRGB(50, 181, 255)
		newButton.bottom.BackgroundColor3 = Color3.fromRGB(20, 151, 225)
		
		innerGui.Parent = game:GetService("CoreGui")
		innerGui:WaitForChild("stop").Visible = true

		selectedSurface = surfaceType
	end)
end

am I correct when plugin:GetMouse() is the issue? if so or not, how can I fix this?

I put the other code (addSetButton) to show that enabled gets set to true

Nevermind, I fixed it by putting plugin:Activate(true) when the new button gets pressed

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.