How to deactivate MouseButton1Click

The MouseButton1Click is inside a Function and just after the Function is fired it will work. But it will be activated forever i can click it forever, how to close the MouseButton1Click again?

You can do a debounce, if I think I know what you mena.


local debounce = false
obj.MouseButton1Click:Connect(function()
	if not debounce then 
		debounce = true
		print("Active!")
		task.wait(10) -- An example
		debounce = false
	else 
		warn("Debounce is still active!")
	end
end)

Use :Disonnect() which will disconnect the function

local connection;

local function a()
    -- function stuff

    connection = GuiObject.MouseButton1Click:Connect(function()
        -- some code stuff
        connection:Disconnect()
        connection = nil
    end)
end

a() -- fire the function