Make script addition dependent on onState image being set