UserInputService.MouseBehavior won't lock center

I’ve been locking the mouse center for over-the-shoulder and first-person cameras, and I would simply lock it by changing the MouseBehavior of UserInputService to LockCenter, but now that doesn’t seem to work. Is there something I’m missing here? I loaded up a blank project and put this script into StarterPlayerScripts.

local RunService = game:GetService("RunService");
local UserInputService = game:GetService("UserInputService");

RunService.Heartbeat:Connect(function(dt)
	UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter;
end)

I’ve used it before and it worked, but only if I put it on the heartbeat event, otherwise it would unlock after the first frame. Now, it simply doesn’t lock, and removes the ability to rotate the camera by right-clicking.

Apparently this seems to be an Engine bug

I’m not sure if this will work for you, but I used RenderStepped instead of Heartbeat and it worked for me

Edit: Even heartbeat was working for me? Strange…

I’ve listed an answer here you should try:

Thank you! I also figured an odd workaround, it seems to only stay unlocked if I have tool panels on the left and right of the studio. If I take off the left tool panel, then it locks correctly.


Because of this however, I’m not certain it has to do with that known bug. I don’t know if it is the resolution and therefore how it would work on smaller res devices once shipped. I’ll take a look at those lines in the old and fixed versions of the playermodule, and if I can figure out the reason I’ll post something again on this thread for others who possibly have this problem.