Reading the FNaF wiki and on the article on Foxy it says
It is theorized by many that Foxy doesn’t actually want to kill the player, but is simply checking up on the player. If he doesn’t see the cameras moving he might assume that the player has been caught and rushes to the office to make sure the player is okay, but inadvertently scares the player to death and another animatronic comes along and stuff the player’s body into a suit. Viewing him too many times may make him think that the player is becoming paranoid so he rushes to the office to try and calm the player down, but ends up accidentally killing him the same way. This is supported by the fact the he doesn’t jump in front of the player but rather just sticks his head in. He may also scream when he enters the office because his voice box is broken and degraded from being in disrepair, and may actually be trying to talk to the player.