Servo run in one direction instead of following slider movement

Dear @Mus_Sopee,
If you have doubts regarding those codes…start using the “search” function in this site, you will find several examples about your project that will help you as example:

Check also below link for better understanding about for statement:

Regards!