How do I get this to only go forward?

How do i get this to only go forward? but still have the y axis, iv just do not what the character to go back.

Have you considered simply using the physics in Unity? it makes it way easy.

the basic idea: NEVER move an item yourself, nor set the velocity.

Just AddForce.

essentially just change your last line to rigidbody.addforce … see millions of examples everywhere!