Scripts are somewhat difficult to debug, since they do not have a fully fledged IDE keeping up to date on all the variables that exist. There are things you can do however to help you identify what's going on.
The following example demonstrates a way of printing out what a particular variable is.
This makes use of the engine's warning feature to send you information in a box. In this example, triggerer can be anything, text, an entity, an instruction.. it will print the input's toString() method if available.
More methods of debugging to come!