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

pinMode(echoPin, INPUT); // echoPin as an Input
  }  // this curly bracket is in the wrong place.
  Serial.begin(9600);

The misplaced curly bracket ends the setup function early. Move that curly bracket to the end of the setup code like so:

Serial.begin(9600);
  myServo.attach(10); // Pin Connected To Servo
}  // this is where the bracket belongs