How to calculate the residence time autocorrelation function of water near a specific (ionic) group?

Dear all

I want to calculate the residence time that many people calculate by Gromacs. Can it be calculated in MS? Is there a suitable script for this? Thank you in advance.