I have a 1987 200sx xe that wont let me go past 4000 rpms while I'm driving in gear its almost like it hits an imaginary wall but when i put it in neutral it will rev past 4000 rpm but it has a hard time.

pressure test the fuel pump to see if it's weak. If not that, pressure test the catalytic converter to see if it's clogged up inside