Probably the way Note Trackers work. Also a sustain Scriptlet is not the easiest Scriptlet you could start with. Have a look here:
I hope it helps