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 9 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

mouse.Changed:connect(function()
mouse.Y = 0
mouse.X = 0
end)

2 answers

Log in to vote
5
Answered by 9 years ago

You can use UserInputService to do this:

game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
Ad
Log in to vote
-4
Answered by
iFlusters 355 Moderation Voter
9 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 :

local Player = script.Parent.Parent
local mouse = Player:GetMouse()

function CenteredMouse()
-- Code
end

-- Call the function
0
I've already got the Player and Mouse thing done ScriptingCon 52 — 9y

Answer this question