Why is my rigidbody.velocity not working?

Hi Unity devs,

I am having a GameObject with a sprite script added to it. I have attached a boxcollider and a rigidbody as well to that object and I am trying to execute this:

 void Update() {
 float jumpspeed = 8.0f;
   if (Input.GetKeyDown (KeyCode.Space))
     {
       rigidbody.velocity += jumpspeed * Vector3.up;

     } 
 }

This script is attached to the current gameobject.

Here nothing seems to be happening when I press spacebar.

Why is that so?

that code is working fine here, maybe you are using a different up vector… try with other vector3 directions.