Try switching selection type to index instead of smart variable before recording the script.
Also, then you can replace GetRootPart().Bodies[0].Faces[0] by the following in the selection create:
g1 = Window.ActiveWindow.Groups[0] # access the first group
g1.Members[0] #first entity in named selection group
-Aniket
How to access Ansys help links
Guidelines for Posting on Ansys Learning Forum