Wrathchild,
I am glad you got this solved in other ways, but in possible answer to the question, it is most likely that your script is requesting a variable of one type, ie. a number, but that parameter is actually defined as something else such as text. This type of mismatch will generate the error message you have.
HTH
Erich
AC 19 6006 & AC 20
Mac OS 10.11.5
15" Retina MacBook Pro 2.6
27" iMac Retina 5K