Detect difference between mouse holding and clicking

Hi DevForum!

How would i detect the difference between the mousebutton being held down and the mousebutton being clicked. I have an item slot and i want it so when i click the slot, a menu appears, but when i hold it, i’m able to drag it. How would i achieve this?

Thanks in advance!

Maybe this will work

local holding = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
    if holding then
       holding = false
    end
end)

mouse.Button1Down:Connect(function()
    if not holding then
       holding = true
    end
end)

while holding do
    -- while holding to something
    wait()
end

No, because then holding will be true, even if i click it.

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local connection

mouse.Button1Down:Connect(function()
	print("Mouse down.")
	connection = mouse.Button1Up:Connect(function()
		print("Mouse clicked.")
		connection:Disconnect()
		connection = nil
	end)
end)

The mouse object also has the event “Mouse1Click”, not sure exactly what you’re trying to achieve.

Ah yes, that’s what i was looking for. Thanks.