Hi.
I’m trying to figure out how to lock the mouse cursor to the middle of the client’s screen using UserInputService.MouseBehaviour = Enum.MouseBehaviour.LockCenter but it’s not working and has nothing in output. What can I do here?
Try and set the cursor to {0.5, 0}{0.5, 0} - I don’t know if this will work but it should set it to the centre.
The control scripts are setting MouseBehavior back, so to stop that you will need to set it every frame.
local RunService = game:GetService"RunService"
local UserInputService = game:GetService"UserInputService"
RunService:BindToRenderStep("MouseLock",Enum.RenderPriority.Last.Value+1,function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end)
The mouse.X
and mouse.Y
properties are a read-only property, so you can only see them you can’t change them or anything. And as well each property is a number value, not a Udim2 and they are separate so it’s not like mouse.Position
I wish there was a way to control the mouse more.
You can not [directly] control the mouse cursor position. Being able to do so would have some security implications. However, you can create a pseudo-cursor and manipulate that to your liking.
To a solution to this, use a Gui that hides all the screen and set the transparecy of the gui to 1