# Script synatax on value change

**URL:** <https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087>\
**Category:** Ignition\
**Created:** [October 5, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087 "2023-10-05T16:24:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan\_mueller](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dan\_mueller](https://forum.inductiveautomation.com/u/dan_mueller)\
**Post date:** [October 5, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087/1 "2023-10-05T16:24:12Z")

</div>

I want to write a script on value changed and assign the value of a different tag to the current tag

```auto
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	"[.]Target_new" = "[.]Target"

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 5, 2023, 5:03pm UTC](https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087/2 "2023-10-05T17:03:43Z")

</div>

Literal strings are not equivalent to tag values or writeable. You need to use the `system.tag` functions to read and write your two tags. If the script you're authoring is on the `Target` tag, then you can use something like this:

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	system.tag.writeBlocking("[.]Target_new", currentValue.value)

```

[https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking](https://docs.inductiveautomation.com/display/DOC81/system.tag.writeBlocking)

---

<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:** [October 5, 2023, 5:06pm UTC](https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087/3 "2023-10-05T17:06:57Z")

</div>

> [@dan\_mueller](#):
>
> assign the value of a different tag to the current tag

That seems backwards. If you want one tag to follow changes on another, you need to put the script on the **source** tag. Or make the destination an **expression tag** pointing at the source.

---

<div class="post-metadata">

**Author:** ![dan\_mueller](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dan\_mueller](https://forum.inductiveautomation.com/u/dan_mueller)\
**Post date:** [October 5, 2023, 7:03pm UTC](https://forum.inductiveautomation.com/t/script-synatax-on-value-change/80087/4 "2023-10-05T19:03:50Z")

</div>

Thank you, exactly what I needed.
