help with freezing 2D sprite rotation

i’m very new to C# and trying to learn , so i often get my code from questions like this and try to understand them, but i hit a roadblock, i’m trying to make a 2D top-down game,and i don’t want my objects to rotate, only change animations based on my mouse location, but the code i have is rotating the rigidbody, here’s my code

public class movement_mouse : MonoBehaviour
    private float offset, clampDistance, moveSpeed;

    public Transform anchor;
    public Animator anim;

    void Update()
    public Transform Aiming()
        //Position dans l'écran
        transform.position = Vector2.Lerp(anchor.position, Camera.main.ScreenToWorldPoint(Input.mousePosition), moveSpeed);

        Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        float angle = (Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg) + offset;
        transform.rotation = Quaternion.Euler(0f, 0f, angle);

        angle += 22.5f;
        angle %= 360;
        if (angle < 0)
            angle += 360;

        // find the frame and show it
        int frameIndex = (int)angle / 45;
        anim.SetFloat("x", frameIndex);
        return transform;

any help is good, thx! also, sorry for bad english, not my primary language

“I don’t want it to rotate but the code I use is rotating it” here is the code … mhhhh ok

just in case, there are things not in the code like FreezeRotationX

in rigidbody hierachy

figured it out, turns out i am extremely dumb and didn’t figure out
transform.rotation = Quaternion.Euler(0f, 0f, angle);
rotated the player on the z axis, it’s now fixed and i will now go cry in the bathroom in an attempt to drown my stupidity, farewell