What's wrong with this script

I am a beginner.

I was watching a tutorial on how to find the velocity of the player and I wrote This Script:

GameObject.GetComponent(Rigidbody2D).velocity = new Vector2(MoveX * PlayerSpeed, GameObject.GetComponent(Rigidbody2D).velocity.y);

and it shows this error twice on the same line:

Error CS0120: An object reference is required for the non-static field, method, or property ‘GameObject.GetComponent’

var rigidBody = gameObject.GetComponent();
rigidBody.velocity = new Vector2( MoveX * PlayerSpeed , rigidBody.velocity.y );