UserInputService:IsMouseButtonPressed(...) incorrectly returns true on Windows 10

When I use a Windows 10 client in windowed mode, press and hold my LMB, move my cursor out of frame, release the LMB, and move my cursor back into the frame, UserInputService continues to report the mouse button as being down. Note that I have tried to test this in Roblox Studio on MacOS and the problem did not exist there. Also note that at no point during these steps did focus change to a different window / program.

I have created a very simple repro file. It has the following contents in a LocalScript placed under StarterPlayer.StarterPlayerScripts:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputChanged:Connect(function(inputObject)
	if inputObject.UserInputType ~= Enum.UserInputType.MouseMovement then
		return
	end
	
	print("Left mouse button is currently", UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and "down" or "up")
end)

If you publish this file to a place, jump into that place in a Windows 10 client, press F9 to bring up the developer console, scroll to the bottom of the developer console’s output, and follow the steps outlined above, you should expect to see that when your mouse comes back into the frame after releasing LMB outside of the frame that the output gets new lines saying Left mouse button is currently up, but instead you will see Left mouse button is currently down, despite having released the LMB.

MouseButton1DownOutsideWindowBug.rbxl (18.3 KB)

1 Like

Hi @ProbableAI - thank you for reporting this issue! Interesting that it is only occurring on Windows 10. I’ve created a ticket for us to investigate this - thanks again for all the detailed information in your post!

1 Like

Continuing the discussion from UserInputService:IsMouseButtonPressed(…) incorrectly returns true on Windows 10:

Hello, sorry for bumping up this old post, but I am here to address that:
This bug also occurs on the Roblox engine for Mac (not studio).

  1. When you hold down your left mouse button (LMB) in a Roblox client, UserInputService’s IsMouseButtonPressed(Enum.UserInputType.MouseButton1) will return true.
  2. If you hold your mouse while moving outside of the Roblox window, it’ll still return true.
  3. When you release your mouse while it is outside the Roblox window, it’ll still be true.
  4. Moving your mouse back inside the window after releasing it outside, the function will still return true.
  5. Re-clicking the LMB inside the window and releasing it will finally make the function return false.

What should be expected is that the function returns false starting from 3.

I just noticed this bug recently, but I believe it has been around for a long time.
I am running Roblox on a macOS Monterey.

You can test out the bug in this game New Orleans 1815 - Roblox.
Here is a rbxm file if for testing out the bug.
UISTestScript.rbxm (9.3 KB)

And a video demonstration.