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

How do I keep mouse centered?

Asked by 10 years ago

I'm trying to keep my mouse centered on the screen so I can make a third person view in my game. This doesn't work but yeah :P

1mouse.Changed:connect(function()
2mouse.Y = 0
3mouse.X = 0
4end)

2 answers

Log in to vote
5
Answered by 10 years ago

You can use UserInputService to do this:

1game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
Ad
Log in to vote
-4
Answered by
iFlusters 355 Moderation Voter
10 years ago

There's actually a built-in way to get the players mouse, you'd need to make a local script and put it in StarterPack or StarterGui :

1local Player = script.Parent.Parent
2local mouse = Player:GetMouse()
3 
4function CenteredMouse()
5-- Code
6end
7 
8-- Call the function
0
I've already got the Player and Mouse thing done ScriptingCon 52 — 10y

Answer this question