How do I center my camera

I want my camera to rotate to follow this moving block, but it’s off centered

local maxTilt = 50
RUN_SERVICE.RenderStepped:Connect(function()
      local x = math.rad((((-mainObj.Position.Z - MOUSE.ViewSizeY / 2) / MOUSE.ViewSizeY)) * -maxTilt)
      local y = math.rad((((-mainObj.Position.X - MOUSE.ViewSizeX / 2) / MOUSE.ViewSizeX)) * -maxTilt)
      local z = 0
            
      CUR_CAM.CFrame = MAP:WaitForChild("GameCam").CFrame * CFrame.Angles(x, y, z)
end)

Nevermind, I figured it out, thank you though

It would be easier to use CFrame.lookAt, e.g. gameCam.CFrame = CFrame.lookAt(gameCam.CFrame.Position, movingBlockPosition)