Attach() resets servo's angle
You can avoid using the attach(); method by programming without the servo library.

  for(x=0; x&lt;150; x=x+1)
  {
    digitalWrite(Servomotor, HIGH);
    delayMicroseconds(2350); //Change the delay here to change the angle it goes to
    digitalWrite(Servomotor, LOW);
    delayMicroseconds(18550);
  }


This is an example code for how it worked for me. It sends a pulse to the servo which makes it turn a bit until it reaches a "barrier".