Take a look at the code inside to get the way to code the fading effect. Feel free to copy and use it! You can change the number of repetitions, the time between each repetition, and the effect strength however you like.
Made by myself