Rotate towards mouse pointer

I want to make an arrow rotate towards the mouse pointer, but instead it rotates towards the player character.

The player character has a camera tagged “MainCamera” on them.

    public float speed = 5f;

    private void Update()

        Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, speed * Time.deltaTime);

Ive spent a days on this crap and it turns out its all because my camera perspective was set to projection instead of orthographic