I'm thinking it may have something to do with mouse.X and Mouse.Y but I don't know the values.
The UserInputService
has a property called MouseBehavior
which sets the behavior of the mouse in 3 ways:
Enum.MouseBehavior.Default: Sets the mouse normally and the mouse moves freely
Enum.MouseBehavior.LockCenter: Centers the mouse on the screen
Enum.MouseBehaviour.LockCurrentPosition: Locks the mouse in the current position that it's at
To use this property, simply call the service and set its property to one of the 3 enums, like so:
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
Hope this helped!
For more info about the UserInputService, click here: UserInputService
NOTE: The UserInputService
can ONLY be used from localscripts
. Do not attempt to use it in a server-side
script or it won't work