Brilliant, thank you!
For some reason adding -a let clearall work
If I type just /clearall it's fine but in the script it needs -a to achieve the same thing.
Thanks for the heads up about timers. I was looking for pause or wait or sleep but not timer. Should have thought of timer.