Perl Script Error When Run in Materials Studio

Hi,

I am trying to run a Perl Script in Materials Studio, but I keep getting the following error:

"Unable to get root document from scope in Forcite.Analysis (function/property "MeanSquareDisplacement") "

I've run this script in the past on different projects and it's worked and I believe everything is in the correct directory. Specifically, I'm running CentroidMSDAndXYZ.pl, which was originally written by Reinier Akkermans and was modified by Matthew Kweon and Kaitlyn Dwelle. I've attached the file with all of the scripts in it.