How would we know what might be the error?
Use the "Code Sample" editor to post your script (it's the 5th icon from the left on the Format Bar; the one with the "101 010" graphic), or attach the script (as a .TXT file) to your post.
Does the script produce any error output? Does the script abort or does it run to completion but produces no output? HOW does the script not work?