MouseBehavior.LockCenter stops working in studio after switching tabs

Currently if your test studio client uses MouseBehavior.LockCenter to lock the mouse while in first person and you switch tabs, the mouse stops being locked and moves freely when you return back to studio.

Video Demo

[Explanation of video]

  • I’ve spawned in with mouse lock working normally
  • I turned the cursor visibility on to show where it is
  • I alt-tabbed out of the studio window and returned back in
  • Mouse is no longer locked and I can’t move the camera anymore

This bug was only introduced recently and was not an issue before.

It greatly affects work flow because I can’t test multiple test player clients reliably when I need to constantly switch between studio windows.

4 Likes

Yeah, this just came up as an issue for me. Took me a while to figure out what was going on. I thought some code somewhere was doing it. I can’t find any core scripts that are touching the property.

For now, I’m fixing this by using WindowFocused and resetting the mouse behavior:

userInputService.WindowFocused:Connect(function()
	userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
11 Likes