# Script Troubleshooting

**URL:** <https://forum.inductiveautomation.com/t/script-troubleshooting/106266>\
**Category:** Ignition\
**Created:** [May 14, 2025, 5:36pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266 "2025-05-14T17:36:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 5:36pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/1 "2025-05-14T17:36:48Z")

</div>

Hello,

I am wondering how one is supposed to troubleshoot script code within the designer? I have run into a couple situations where code just doesn't execute and I cannot seem to find any way of easily troubleshooting what is going on. Is there no output or build window that gives some insight? Maybe a breakpoint I can insert to see if the pointer is even reaching that line of code? Or does one simply troubleshoot with outputting stuff to a debug window or text file?

For example, I wrote the following code in a script within a button click event and it would turn the tag on but not off. I forgot to import sleep function from time and it just seemed to stop executing at that function call. Once I imported the function it worked as intended, of course.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/2/d2d0bc2c4ae18f2fb7c9caa40cf998247caa2fdd.png)

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 14, 2025, 5:41pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/2 "2025-05-14T17:41:54Z")

</div>

First... never use sleep.

Second, liberal use of [system.util.getLogger](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-getLogger) to log data.

Thirdly, know your scope.  
If Vision, then errors in the designer show up in the designer diagnostics, or client diagnostics, or the gateway logger.  
If Perspective, then errors show up in the gateway logger.

---

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 5:48pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/3 "2025-05-14T17:48:08Z")

</div>

Hey, thanks for the help...

Would you be able to share some insight as to why I shouldnt use the sleep function? I think you can see what I am trying to do. maybe you have a suggestion on how to properly acheive this? I essentially want to pulse the tag on when the button is pressed.

It is a designer project. I am able to find the issue in the logger file within the gateway as you mentioned. Thanks for showing me that!

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 14, 2025, 5:57pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/4 "2025-05-14T17:57:29Z")

</div>

In Vision, if you are ever using sleep in any sort of fashion, you are pausing a thread. If this is on the UI, then the ENTIRE UI is frozen until the sleep is over.  
In Perspective, it is less of a problem but still the wrong way to accomplish something.

Ignition is highly event driven and tossing in random sleeps is how you create chaos in the backend. I can't speak to all the technical reason, there are guys here that can, but I do know that sleep can and will cause issues.

I assume that you are trying to emulate a one-shot button?

---

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 6:00pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/5 "2025-05-14T18:00:52Z")

</div>

I had a funny feeling what I was doing was not correct / efficient. I am in very early development, and as I am sure you can tell, ignition is quite new to me. I appreciate you taking the time to help me!

I am indeed trying to emulate a one shot button.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 14, 2025, 6:04pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/6 "2025-05-14T18:04:32Z")

</div>

This is perspective correct?

This: [OPC "Start Button" in Perspective - #2 by pturmel](https://forum.inductiveautomation.com/t/opc-start-button-in-perspective/70396/2) would be what I would recommend. Set via OPC, not tag, and then once the PLC receives the command reset in the PLC.

---

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 6:06pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/7 "2025-05-14T18:06:38Z")

</div>

right, and I would have already done that if I was communicating with a normal PLC... In this case it is going to an AMR robot and I don't really have access to be able to just write a 0 back to the tag... easily at least... is there another way you can suggest I take to achieve this? the sleep does work, but i understand your point, and would like to understand the correct way to handle this.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 14, 2025, 6:11pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/8 "2025-05-14T18:11:38Z")

</div>

In this case, I would probably write both the value to the device, as well as a unique memory tag, or a custom property, that is x time into the future to represent when you want to reset the tag. Then, having a gateway timer script that is running, check through button values and any that are on, read the tag that represents when that button needs to get reset. If the current time is \>= than the time to reset and the button tag is 1, then turn button tag off.

---

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 6:13pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/9 "2025-05-14T18:13:56Z")

</div>

understood. It seems like quite the complex solution for something seemingly so simple. not saying you are wrong by ANY stretch, i just would have never thought this would be how to acheive this.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [May 14, 2025, 6:20pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/10 "2025-05-14T18:20:01Z")

</div>

Better than `sleep` but probably still frowned upon, I sometimes use a `Timer` to achieve a delay:

```python
from threading import Timer

def doLater(self):
	self.doneLater = True

Timer(0.5, doLater, [self]).start()

```

---

<div class="post-metadata">

**Author:** ![dWiseman](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dWiseman](https://forum.inductiveautomation.com/u/dWiseman)\
**Post date:** [May 14, 2025, 6:24pm UTC](https://forum.inductiveautomation.com/t/script-troubleshooting/106266/11 "2025-05-14T18:24:54Z")

</div>

Thanks, Ryan. I did see this as well when looking up solutions.
