Doh. There's a typo in my code (that will teach me to post code off the top of my head at 3 a.m.):
Line five should be:
$render = isset($scriptProperties['render']) && $scriptProperties['render'];
not
$render = isset($scriptProperties['render']) && $scriptProperties['render']);
Remove the extra ) at the end of the line.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html