If your car won't go over 40 MPH but the engine still goes faster and faster as in the RPM goes up higher and higher but the car doesn't pick up speed then it's possible that the transmission could have problems and need fixed or replaced.
Or you could have a clogged transmission filter or low transmission fluid.
Check your transmission fluid and if the transmission fluid is too low then add some transmission fluid until the transmission is full of fluid.
Make sure to use the proper type of transmission fluid as well otherwise the transmission could be damaged.
You might have to get a new transmission or have your current transmission rebuilt or get another car if the car is not worth the repairs.