So how do I rotate my camera to my player

So every time I want to right click, I want to move my camera to where my mouse is, and rotate my player to my camera. But instead when I right click my camera just go crazy like a madlad. my camera is a isometric btw.

Here my code yall madlads.
public CharacterController controller;

    public float speed = 12f;
    public float gravity = -9.18f;
    

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;

    Vector3 velocity;
    bool isGrounded;
    public Transform maincamera;
    void Update()
    {
        transform.LookAt(maincamera);
        transform.LookAt(maincamera, Vector3.left);
    }
    
       

    float AngleBetweenTwoPoints(Vector3 a, Vector3 b)
    {
        return Mathf.Atan2(a.y - b.y, a.x - b.x) * Mathf.Rad2Deg;
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        if (Input.GetKey("left shift") && isGrounded)
        {
            speed = 20f;
        }
        else
        {
            speed = 12f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

       

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}
public class cameraSystem : MonoBehaviour
{
    public Camera cam;
    public float speed = 5.0f;
    Vector2 movement;
    Vector2 mousePos;
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            Debug.Log("Aiming");
            transform.position = new Vector3(speed * Time.deltaTime, 0, 0);
            // If the right button on the mouse is hold down or click it moves the camera to it position.

        }
    }
}

// Have “player” as a variable of type gameobject and assign in inspector
Vector3 playerPosition = player.transform.position;

// This class is assigned to the camera object
Vector3 cameraPosition = transform.position;

Vector3 dirBetween = (playerPosition - cameraPosition).normalized;

// Rotate camera to look at player
transform.forward = dirBetween;

// To rotate player to look at camera: player.transform.forward = -dirBetween;