function-definition is not allowed here before '{' token ERROR

For starter

Serial.begin(9600);
  myServo.attach(10); // Pin Connected To Servo

is outside setup().

There might be more wrong.