#[UNSOLVED] Custom first person camera not turning on the Y axis

9 messages · Page 1 of 1 (latest)

upbeat wharf
#
local inputService = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character

local sensitivity = 0.2 -- adjust this value to control the sensitivity of the camera movement

local lastMousePosition = inputService:GetMouseLocation()
local pitch = 0

inputService.InputChanged:Connect(function(input, gameProcessed)
    if not gameProcessed and input.UserInputType == Enum.UserInputType.MouseMovement then
        local mouseDelta = input.Delta
        local mouseYDelta = mouseDelta.y * sensitivity
        pitch = math.clamp(pitch - mouseYDelta, -89, 89) -- limit pitch to prevent flipping

        camera.CFrame = CFrame.new(character.HumanoidRootPart.Position) *
                        CFrame.Angles(math.rad(pitch), 0, 0) *
                        CFrame.Angles(0, math.rad(-mouseDelta.x * sensitivity), 0)

        lastMousePosition = inputService:GetMouseLocation()
    end
end)
#

i changed it quite a bit, but i think this should work :)

upbeat wharf
#

fuck

#

im sorry about that

#

let me try something else

willow kindle
#

hello

#

I'm a little confused on what you're trying to accomplish, the game already will autorotate your player and let you look up and down with your mouse. Is there something specific you're trying to achieve with this?

upbeat wharf
willow kindle
#

I did, my question is why cframe it at all