You shouldn't wrap the UDFs inside the IF condition.
code:
IF INGROUP (group)
FOR EACH $file IN $templates
IF NOT Exist('$destination\$file')
COPY '$directory\$file' '$destination'
ENDIF
NEXT
ENDIF
FUNCTION...

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.