My script to change directions with the press of a button isn't working Help!

public class FootballMoveMent : MonoBehaviour
{

public float VerticalSpeed;
public float HorizontalSpeed;

public bool kicked;

// if direction = 1, right. if direction = 2, left //
public float direction = 1f;

private void Start()
{
    kicked = false;
}
void Update()
{
    if ( Input.GetKey("r") &&  direction == 1)
    {
        
            direction++;
        
        
    }
    if (Input.GetKey("r") && direction == 2)
    {

        direction--;

    }

    if (Input.GetKey("f"))
    {
        kicked = true;
    }
    
    if (kicked == true) 
    {
        if (direction == 1)
        {
            transform.position += transform.right * HorizontalSpeed * Time.deltaTime;
        }
        if (direction == 2)
        {
            transform.position -= transform.right * HorizontalSpeed * Time.deltaTime;
        }
    }

That’s because your both if statements that look for “r” key will trigger in same update because first if statement updates direction to “2” then second if triggers and changes it back to “1”
Change it to:

if (Input.GetKey("r"))
{
     if (direction == 1)
     {
          direction++;
     }
     else
     {
          direction--;
     }
         
}

All your code can be optimised actually if you used “-1” for left:

void Update()
{
    if (Input.GetKey("r"))
    {
        direction *= -1;
    }
  
    if (Input.GetKey("f"))
    {
        kicked = true;
    }
     if (kicked == true)
    {
        transform.position += direction * transform.right * HorizontalSpeed * Time.deltaTime;
    }
}