hello im making a game where u are a cube animal thing and u have a gun and the gun is looking at mouse point but iv made my movement system so the character scale goes to the negative so the sprite flips but that inverst the gun controls and im trying to fix it. i got this error and i dont know how to fix it

heres all the scripts involved
private float speed = 14f;
private float horizontal;
private float jumpingPower = 20f;
private bool isWallSliding;
private float wallSlidingSpeed = 0.9f;
private bool isWallJumping;
private float WallJumpingDirection;
private float WallJumpingTime = 0.2f;
private float WallJumpingCounter;
private float WallJumpingDuration = 0.4f;
private Vector2 WallJumpingPower = new Vector2(5f, 14);
private bool isFacingRight = true;
[SerializeField] private Rigidbody2D rb;
[SerializeField] private Transform groundCheck;
[SerializeField] private LayerMask groundLayer;
[SerializeField] private Transform wallCheck;
[SerializeField] private LayerMask wallLayer;
void Update()
{
horizontal = Input.GetAxisRaw("Horizontal");
if (Input.GetButtonDown("Jump") && IsGrounded())
{
rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
}
if (Input.GetButtonUp("Jump") && rb.velocity.y > 0f)
{
rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
}
WallSlide();
WallJump();
if(!isWallJumping)
{
Flip();
}
}
private bool IsGrounded()
{
return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
}
private bool isWalled()
{
return Physics2D.OverlapCircle(wallCheck.position, 0.2f, wallLayer);
}
private void WallSlide()
{
if(isWalled() && !IsGrounded() && horizontal != 0f)
{
isWallSliding = true;
rb.velocity = new Vector2(rb.velocity.x, Mathf.Clamp(rb.velocity.y, -wallSlidingSpeed, float.MaxValue));
}
else
{
isWallSliding = false;
}
}
private void FixedUpdate()
{
if(!isWallJumping)
{
rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}
}
private void WallJump()
{
if(isWallSliding)
{
isWallJumping = false;
WallJumpingDirection = -transform.localScale.x;
WallJumpingCounter = WallJumpingTime;
CancelInvoke(nameof(StopWallJumping));
}
else
{
WallJumpingCounter -= Time.deltaTime;
}
if(Input.GetButtonDown("Jump") && WallJumpingCounter > 0f)
{
isWallJumping = true;
rb.velocity = new Vector2(WallJumpingDirection * WallJumpingPower.x, WallJumpingPower.y);
WallJumpingCounter = 0f;
if(transform.localScale.x != WallJumpingDirection)
{
isFacingRight = !isFacingRight;
Vector3 localScale = transform.localScale;
localScale.x *= -1f;
transform.localScale = localScale;
}
Invoke(nameof(StopWallJumping), WallJumpingDuration);
}
}
private void StopWallJumping()
{
isWallJumping = false;
}
private void Flip()
{
if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
{
isFacingRight = !isFacingRight;
Vector3 localScale = transform.localScale;
localScale.x *= -1f;
transform.localScale = localScale;
}
}
}
sorry if most of its a dumb mistake im very new to working with unity and C#
