Script to add IP of failed IPSEC login to block list

you are getting the line id, they looks like this:

*lb60;*lb61;*lb62"

so that is correct.
You should read trough the script manual and try to learn scripts.

Start with these pages:
https://wiki.mikrotik.com/wiki/Manual:Scripting
https://wiki.mikrotik.com/wiki/Scripts
https://wiki.mikrotik.com/wiki/Manual:Scripting-examples
http://forum.mikrotik.com/t/useful-scripts/36579/1