Mouse.Button1Down/Button1Up not working while in gui

While working with a inventory dragging system, I’m trying to detect when the mouse button 1 is down. But while hovering over a GUI element it stops working.

Code:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local MouseDown = false

Mouse.Button1Down:Connect(function()
	MouseDown = true
	print("Mouse down")
end)

Mouse.Button1Up:Connect(function()
	MouseDown = false
	print("Mouse up")
end)


In the video, I demonstrate my problem. When I hover over the GUI I do hold down my mouse button 1.

Does that particular GuiObject have Active set to true?

Have you tried using UserInputService.InputBegan and checking for UserInputType of MouseButton1?

2 Likes

No I haven’t, thanks! I’ll try it out!