GetComponent.Addforce() not working

I tried both the ways but its not working
I am using unity 2019.6.0a3

    public float speed = 4.5f;
    public float MovementAmplitude = 0.1f;
    public float MovementFrequency = 2.25f;
    public float JumpingForce = 450f;
    // Start is called before the first frame update
    void Start()
        //transform.position = new Vector3(-3.21f, 3.833f, -38.004f);

    // Update is called once per frame
    void Update()
        transform.position += speed * Vector3.forward * Time.deltaTime;
        transform.position = new Vector3(
            Mathf.Cos(transform.position.z * MovementFrequency)*MovementAmplitude,
    ) ;
        //GvrPointerInputModule.Pointer.TriggerDown || 
        if (Input.GetKeyDown("space"))
            Debug.Log("SPace is pressed");
            //GetComponent<Rigidbody>().AddForce(Vector3.up * JumpingForce);
            Rigidbody rb = GetComponent<Rigidbody>();
            rb.AddForce(Vector3.up * JumpingForce);

It probably is a problem cause due to you hardcoding the movement on the transform, it is rewriting the y position, so the force is applied but is not able to move it, if you are going to program the movement on the rigid body, everything should be on the rigid body, and if it is going to hardcoded in the transform, leave it all in the transform