I’ve recently been struggling with trying to get the mouse to stay at the centre of the screen.
I’ve tried changing the MouseBehavior of UserInputService to “Enum.MouseBehavior.LockCenter” but this lasts for like a frame and is quickly switched back to Default.
I’ve tried finding other posts about this issue as the page on DevHub shows it only needs to be set once. My current “fix” is setting the MouseBehavior to LockCenter in a function connected to a RunService event but I don’t understand why this should be necessary.
Is there a reason why the MouseBehavior always reverts back to Default and is it possible to avoid this?
Is there a way to lock the mouse position to the center efficiently rather than continuously?
Your original attempt was correct. Setting the MouseBehavior to LockCenter should work. If it’s not working, then that means other code is setting it back to Default. I would check your code to make sure it’s not inherently resetting it right away.
Try opening a new place file and simply setting the MouseBehavior to LockCenter from a LocalScript and do nothing else. See if this works. If it works, then your original code might have an issue. If this does not work, then this is a bug & I would bet the bug exists within the core player scripts.
Yeah, it’s a bug. Had the same issue when I was doing this for myself as well and had searched the dev forums all over and the only conclusion that I could get to from multiple posts was to just run a renderstepped loop that overrides the camera script setting, this obviously isn’t very efficient so it would probably be better to tamper with the character camera script to possibly add a function that goes inbetween the automatic setting which can be enabled and disabled. As for anything else, nothing has worked for me. API is outdated and has been an ongoing problem for a long while