# Setting a variable to 5 seconds from a button in perspective

**URL:** <https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 25, 2025, 11:28am UTC](https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760 "2025-06-25T11:28:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukasz\_Wieckowski](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Lukasz\_Wieckowski](https://forum.inductiveautomation.com/u/Lukasz_Wieckowski)\
**Post date:** [June 25, 2025, 11:28am UTC](https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760/1 "2025-06-25T11:28:04Z")

</div>

Hi.  
I have a problem with calling the setting of a tag from a button in perspective to true for 5 seconds. I would like to set the tag to true for 5 seconds and then have it return to false after 5 seconds. I manage to set tag to true, but it does not return to false after 5 seconds.

My code under the mouse event button

```
system.perspective.print("Start script:")

tagPath = "[Ignition_IO_01_NE_KRASNOPOL]NE_KRASNOPOL/LV_On"
system.perspective.print("Set path")

system.tag.writeBlocking([tagPath], [True])
system.perspective.print("Set tag")

system.util.invokeLater(
	lambda: system.tag.writeBlocking([tagPath], [False]),
	5000 # opóźnienie w milisekundach
)

system.perspective.print("Reset tag")

```

Unfortunately the variable does not return to false after 5 seconds

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 25, 2025, 11:39am UTC](https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760/2 "2025-06-25T11:39:43Z")

</div>

`system.util.invokeLater()` doesn't exist in gateway or Perspective scope. It is a Vision-only function.

---

<div class="post-metadata">

**Author:** ![Lukasz\_Wieckowski](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Lukasz\_Wieckowski](https://forum.inductiveautomation.com/u/Lukasz_Wieckowski)\
**Post date:** [June 25, 2025, 11:48am UTC](https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760/3 "2025-06-25T11:48:11Z")

</div>

What function should i use to reset the tag after 5 seconds?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 25, 2025, 12:02pm UTC](https://forum.inductiveautomation.com/t/setting-a-variable-to-5-seconds-from-a-button-in-perspective/107760/4 "2025-06-25T12:02:55Z")

</div>

If you want it to be reliable, you should use:

- A memory tag that holds the desired future turn-off time, and
- A timer event that checks that and the current state to write the off state when the turn off time is reached. Run that timer event all the time, at a pace that yields the desired precision.
