Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I set a mouse to center screen?

Asked by
Cr0ws 20
8 years ago

I'm thinking it may have something to do with mouse.X and Mouse.Y but I don't know the values.

1 answer

Log in to vote
1
Answered by 8 years ago

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

0
TurboFusion be going around stealing rep. report report for hax now hes making guns for free DragonODeath 50 — 8y
Ad

Answer this question