From the FAA Instrument Flying Handbook, AC61-27C, page 50.
“Another common error results from failure to maintain straight-and-level flight while reading the magnetic compass for the heading to set in the directional gyro. Errors in the magnetic compass induced by attitude changes are thus duplicated in the heading indicator.”
I’m surprised a CFI told you differently as this is basic stuff that your need to know before going on cross-country flights. You should contact him/her and let them know in a nice way the correct way, before a student of him/her gets into trouble.