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

Help with locking mouse in ONLY X axis?

Asked by 6 years ago
Edited 6 years ago

So I'm making this game and I'm trying to make it first person where you can still move the mouse up and down. I have created a camera part in the workspace which gives the current camera a position in the world, and the camera follows the mouse, but won't move up or down. I need to lock the mouse in the x position, not the y, to stop it from freaking out. Does anyone know how to do this?

cam = game.Workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local val = false
while wait() do
    if game.Workspace.Game.Value == (true) then
        if workspace.Monitor.Value == (false) then
            cam.CameraType = 0
            if val == false then
                cam.CoordinateFrame = CFrame.new(workspace.MainCam.Position)
                val = true
            end
            cam.Focus = CFrame.new(mouse.Hit.p.X, workspace.MainCam.Position.Y, mouse.Hit.p.Z)
        else
            val = false
            cam.CameraType = 0
            cam.CoordinateFrame = CFrame.new(game.Workspace["Cam"..game.Workspace.CameraId.Value].Position)
            cam.Focus = CFrame.new(game.Workspace["Cam"..game.Workspace.CameraId.Value.."Focus"].Position)
        end
    else
        cam.CameraType = 0
        cam.CoordinateFrame = CFrame.new(game.Workspace.MainCam.Position)
        cam.Focus = CFrame.new(workspace.MainCamF.Position)
    end
end

Answer this question