Right Clicking while In First Person will send Mouse to Center of Screen (if unlocked via Modal)

Whenever I right click whilst in First Person, my mouse is sent to the center of my screen. This is an issue because I unlock the mouse during UI navigation through the use of a Modal. This does NOT happen if the user clicks or is hovering over a button.

I reckon this is because of the CameraModule, but I can’t seem to find what part of the code does this.

Any posts I’ve found relating to my issue only have vague answers or very specific lines to remove that no longer exist.

Any help?

Right clicking which sends the mouse to the center of the screen is actually normal and does not have an issue relating with your code. Roblox makes this happen, but I’m not really sure why. However, as you said:

and after further tests, it doesn’t happen if the player is hovering over a button. But if you don’t want the mouse to send back to the center, you could pretty much place an invisible button with UDim2 being 1, 0, 1, 0 but not make it do anything.

1 Like

Not a bad idea, but I’d rather avoid such a hacky solution. I will mark this as a solution if I can’t find anything else, though.

1 Like

It isn’t really a hacky solution in my opinion, that’s pretty much the best and the most basic way to handle in this situation. But, thanks!

1 Like

Try setting UserInputService.MouseBehavior to Enum.MouseBehavior.Default.

You might need to set it every time the user right clicks, as it seems to reset it.

1 Like

This kind of works, but holding Right Click still locks the mouse in place and moves the Camera. It doesn’t snap it to the center though, so it still seems like a promising solution.