I can almost guarantee that your script trigger is triggering everytime your script uses goto layout, thus creating an endless loop.
If you are using FMPro Avdanced, turn your script debugger on and step through it.
Thanks Peter, You are correct and I resolved the broblem by changing the button set up to run the script, rather than to go to the layout. It works fine now.
If an endless self-triggering loop is the problem, following the suppressible triggered scripts best practice is the solution. However, contrary to the recommendation in the page, I always use this at the start of any triggered script:
If [not TriggersAreActive]
Exit Script [Result:True]