# Breakdown Time gateway script not working

**URL:** <https://forum.inductiveautomation.com/t/breakdown-time-gateway-script-not-working/90362>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition81\
**Created:** [May 14, 2024, 1:53pm UTC](https://forum.inductiveautomation.com/t/breakdown-time-gateway-script-not-working/90362 "2024-05-14T13:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jack\_Wheatley](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@Jack\_Wheatley](https://forum.inductiveautomation.com/u/Jack_Wheatley)\
**Post date:** [May 14, 2024, 1:53pm UTC](https://forum.inductiveautomation.com/t/breakdown-time-gateway-script-not-working/90362/1 "2024-05-14T13:53:54Z")

</div>

I am trying to calculate how many seconds a machine has been broken down in a gateway script. I have made the code increment a tag by 1 each second, but it is not working. Does anyone know why?

Thanks.

 ![Availibility Script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/743c6c7f8a5e17df45f398c813f88d3328c30d57.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 14, 2024, 2:09pm UTC](https://forum.inductiveautomation.com/t/breakdown-time-gateway-script-not-working/90362/2 "2024-05-14T14:09:33Z")

</div>

- When you see `sleep()` in your scripts you know you're lost.
- Never ever use a never-ending while loop in an Ignition script.
- When you need to read multiple tags do them all in one statement using `system.tag.readBlocking` which accepts a list of tags.

Instead:

- Create a gateway tag change event on the machine fault.
- When the fault tag goes true record the time in a memory tag of type DateTime.
- Calculate the downtime using an expression with `now(1000) - the stop time tag value`.

---

<div class="post-metadata">

**Author:** ![Jack\_Wheatley](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@Jack\_Wheatley](https://forum.inductiveautomation.com/u/Jack_Wheatley)\
**Post date:** [May 15, 2024, 10:19am UTC](https://forum.inductiveautomation.com/t/breakdown-time-gateway-script-not-working/90362/3 "2024-05-15T10:19:34Z")

</div>

I am indeed lost, as I am not an avid programmer. Thank you for pointing me in the right direction, I will try this method.
