Why does this happen?

So I want the shotgun to aim at the player for a bit but why the hell does it randomly invert?!? Does anyone know a fix?