My servo is glitching!!!

So i got a Starter kit and i really wanted to make a door lock.
I started building it, but im a beginner so i dont know much.
Here is the code:

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
    // in steps of 1 degree
    myservo.write(pos);              
    delay(15);                       
  }
  for (pos = 180; pos >= 0; pos -= 1) { 
    myservo.write(pos);             
    delay(15);                       
  }
}

What does "glitching" mean?

My guess, and last contribution to the forum before I accept the profile delete confirmation sitting in my inbox, is that you have it powered from the Arduino 5V not from an adequate external supply as shown in zoomkat's well known picture below:

servo-wire.jpg

Of course, nobody would blame you for hooking it up that way since it's how the tutorial actually shows it:

sorry i posted the wrong code
here is the fxed version
https://forum.arduino.cc/index.php?topic=653358.0

"sorry i posted the wrong code
here is the fxed version"

Copy it and post it in a code box so it is is in this discussion.