I have a custom camera but when I set the MouseBehavior to LockCenter it doesn’t allow me to get mouse position. Anyway to get mouse position while locking to the center?
1 Like
If the mouse position is locked to the center, then it would be the center of the screen.
You can find the center of the screen by doing this:
- Have a Screen Gui
- Get AbsoluteSize of Screen Gui
- Divide by 2
Result is the center of your screen
due to the mouse being locked, you should always expect the position to be the screen’s center, with the following script you will always get the genuine mouse location no matter if it’s locked or not.
local CurrentCamera = workspace.CurrentCamera
local UserInputService = game:GetService'UserInputService'
local MouseLocation = UserInputService.MouseBehavior.Name == 'LockCenter' and CurrentCamera.ViewportSize / 2 or UserInputService:GetMouseLocation()
1 Like