My character only jumps but doesn't move.

This is my code. It’s my first project on unity and my character won’t move. It did before but now it just won’t

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
  private bool jumpKeyWasPressed;
  private float horizontalInput;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {

      if (Input.GetKeyDown(KeyCode.Space))
      {
        jumpKeyWasPressed = true;
      }

      horizontalInput = Input.GetAxis("Horizontal");
    }

    private void FixedUpdate() 
    {

      if (jumpKeyWasPressed)
      {
        GetComponent<Rigidbody>().AddForce(Vector3.up * 5, ForceMode.VelocityChange);
        jumpKeyWasPressed = false;
      }
      
      GetComponent<Rigidbody>().velocity = new Vector3(horizontalInput, GetComponent<Rigidbody>().velocity.y, 0);
    }
    
}

i never did 2d but on the if statement: if (jumpKeyWasPressed) you need check if its true or false so add a == sighn make sure its 2 cause if its one it probaly wont do anythig. aslo add a true at the end so then its checking if jumpkeywaspressed equals true. aslo i ddont understand the point of the horizontal input thing at the end it just is two getcomponents idk why you would do that since the more times u do that it makes the game more lagy here is my movement :

[SerializeField] Vector3 V3F;
[SerializeField] KeyCode keyPositive;
[SerializeField] KeyCode keyNegative;

 private Rigidbody Rb;

 private void Start()
{
    Rb = GetComponent<Rigidbody>();
}

void FixedUpdate()
{
   if(Input.GetKey(keyPositive))
  Rb.velocity += V3F;
   
   if(Input.GetKey(keyNegative))
   Rb.velocity -= V3F;

  
}