Oops, the code I gave you before had a little flaw then since I hadn’t been thinking about jump. It’s setting your Y velocity to 0 when at max speed, which is keeping you in the air haha
change this line:
rigidbody2D.velocity = new Vector2(maxSpeed * x,rigidbody2D.velocity.y);
This way, it will essentially leave your Y velocity alone.