This could be due to a missing object reference in your code, could you post the script (using code tags)
Code Tags