Changing webhosting without affecting existing email

Hi!

There is a domain name that is currently configured with email. I want to point the nameservers to some other webhost but I do not want to affect the email settings.

I remember I tried doing something similar a few years ago but just changing the nameservers messed up the email and I had to change mx records or something.

So how could I change the webhosting settings (i guess changing the nameservers) but without affecting the email that is currently working? (My client has been using emails from that domain for a long time now).

Thanks in advance,

Leo