Lock only one mouse axis?

Im working on a camera system and I want that the camera follows the mouse
BUT
I dont want that you can move the mouse up

I tried to use UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter but that locks the mouse

I neeeeeeeeed help :c

Here is my code btw :

local cam = game.Workspace.CurrentCamera

cam.CameraType = Enum.CameraType.Attach

local RunService = game:GetService"RunService"

local UserInputService = game:GetService"UserInputService"

RunService:BindToRenderStep("MouseLock",Enum.RenderPriority.Last.Value+1,function()

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

local face = char:FindFirstChild("HumanoidRootPart").CFrame.LookVector

cam.CFrame = CFrame.new(char:FindFirstChild("HumanoidRootPart").WeaponCam.WorldPosition, Vector3.new(face.X * 9999, char:FindFirstChild("HumanoidRootPart").WeaponCam.WorldPosition.Y, face.Z * 9999))

end)
2 Likes

There is no official function that can lock the mouse into one axis. However, what we can do is create a fake mouse that moves in only one axis and make the real mouse invisible. We then ignore the real mouse

4 Likes