# Script will not change tag value PLC to PLC. I know I have write enabled in PLCs and in gateway

**URL:** <https://forum.inductiveautomation.com/t/script-will-not-change-tag-value-plc-to-plc-i-know-i-have-write-enabled-in-plcs-and-in-gateway/90231>\
**Category:** Ignition\
**Created:** [May 10, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/script-will-not-change-tag-value-plc-to-plc-i-know-i-have-write-enabled-in-plcs-and-in-gateway/90231 "2024-05-10T14:11:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Levi\_Overmyer](https://avatars.discourse-cdn.com/v4/letter/l/5f9b8f/32.png) [@Levi\_Overmyer](https://forum.inductiveautomation.com/u/Levi_Overmyer)\
**Post date:** [May 10, 2024, 2:11pm UTC](https://forum.inductiveautomation.com/t/script-will-not-change-tag-value-plc-to-plc-i-know-i-have-write-enabled-in-plcs-and-in-gateway/90231/1 "2024-05-10T14:11:13Z")

</div>

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):

# Define the source and destination tag paths

source\_tag\_path = "[default]Line1/Data/L1\_RoboticStacker/Ignition\_Retract"  
destination\_tag\_path = "[default]Line1/Data/L1\_RoboticStacker/trg1"

# Get the tag values

source\_tag\_value = system.tag.read(source\_tag\_path).value

# Write the value to the destination tag

system.tag.write(destination\_tag\_path, source\_tag\_value)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 10, 2024, 2:34pm UTC](https://forum.inductiveautomation.com/t/script-will-not-change-tag-value-plc-to-plc-i-know-i-have-write-enabled-in-plcs-and-in-gateway/90231/2 "2024-05-10T14:34:04Z")

</div>

I'll assume that this is for Ignition V8.1, and so you should be using the `read*` and `write*` functions as the ones that you have posted are deprecated.

That being said, everything that you show here should be correct "technically". This would indicate to me that something in the device is writing over your write or you have some other type of race condition. You should only ever write to a tag (PLC or Ignition) from one direction, doing otherwise will cause issues.

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
    source_tag_path = ['[default]Line1/Data/L1_RoboticStacker/Ignition_Retract']
    destination_tag_path = ['[default]Line1/Data/L1_RoboticStacker/trg1']

    source_tag_value = system.tag.readBlocking(source_tag_path)[0].value
    system.tag.writeAsync(destination_tag_path, [source_tag_value])

```

Also, please use the preformatted text option to post code, makes it a lot easier to help and read your code.

---

<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 10, 2024, 4:12pm UTC](https://forum.inductiveautomation.com/t/script-will-not-change-tag-value-plc-to-plc-i-know-i-have-write-enabled-in-plcs-and-in-gateway/90231/3 "2024-05-10T16:12:38Z")

</div>

Levi, please read [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).  
Then please use the pencil link below your post to edit and fix it.  
Thanks.
