Problem with scripts

Could you edit your post to use code tags, like everyone else does? It is really hard to read code without proper formatting, and you’ll probably get more answers if your code is properly formatted.