Call object by string variable

I need to call an object from a specific group that is closer to the player. I need to put the name of this object in a string variable and then, in an action, I need to call the object.X() but not directly using the instance name but the contents of the variable.