How to flip just parent not child,How to only make parent flip not the child

I am making a platformer with a shooting mechansim. I followed the Blackthornprod tutorial (HOW TO MAKE A 2D RANGED COMBAT SYSTEM - UNITY TUTORIAL - YouTube) but after I wrote the script to rotate the weapon towards the mouse I noticed it also flips along with the player.

Here is the shooting script -

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

And here is the flip script -

//Player Horizontal Movement
        float horizontalInput = Input.GetAxis("Horizontal"); 
        rb.velocity = new Vector2(horizontalInput * speed, rb.velocity.y);

        rb.constraints = RigidbodyConstraints2D.FreezeRotation;


        //flip player
        if (horizontalInput > 0.01f)
        {
            transform.localScale = new Vector3(2, 2, 2);
            
        }

        else if (horizontalInput < -0.01f)
        {
            transform.localScale = new Vector3(-2, 2, 1);
            flipHand = false;
        }

I did this on Unity version 2020.3.22f1

Please help me, I’ve been searching on google for about 3 hours to no avail
,I am making a platformer with a shooting mechansim. I followed the Blackthornprod tutorial (HOW TO MAKE A 2D RANGED COMBAT SYSTEM - UNITY TUTORIAL - YouTube) but after I wrote the script to rotate the weapon towards the mouse I noticed it also flips along with the player.

Here is the shooting script -

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

And here is the flip script -

//Player Horizontal Movement
        float horizontalInput = Input.GetAxis("Horizontal"); 
        rb.velocity = new Vector2(horizontalInput * speed, rb.velocity.y);

        rb.constraints = RigidbodyConstraints2D.FreezeRotation;


        //flip player
        if (horizontalInput > 0.01f)
        {
            transform.localScale = new Vector3(2, 2, 2);
            
        }

        else if (horizontalInput < -0.01f)
        {
            transform.localScale = new Vector3(-2, 2, 1);
            flipHand = false;
        }

I did this on Unity version 2020.3.22f1

Please help me, I’ve been searching on google for about 3 hours to no avail

I can’t speak to your specific tutorial, but I would probably just avoid childing the weapon to the player in this scenario.

Create a parent player object (it could be empty) and child the player model to that, then child the weapon to that.

That is, the weapon is not a child of the player. It is a sibling of the player model.

This will likely break some of your scripting but should be easy to fix depending on how heavily you’re leaning on the tutorial for help.

Thanks!

I actually figured that out yesterday, and I had to split the script to make seperate scripts for animation and movement, but it worked!