It sounds like you've just found this code online somewhere and don't actually understand most of what it's doing. If you want to actually learn how to script look through the tutorials on this forum, this one is a good place to start:
Not many people are willing to spoonfeed others