Reducing variable on object, new value not showing in text object

Part of my game has cities generating resources every few seconds: wheat and gold.

Here’s how it works (screenshots at the end for reference):

  • Every 1 second, each location object’s cityResourcesStored.wheat variable gets added to by the cityResourcesOutput.wheat total. In this example, it’s 10 every second

  • When I click on the location object, a City View layer appears, and along with the location object name as a text object, there are Wheat: X and Gold: X text objects with the current cityResourcesStored.wheat (and one for gold) values. This works fine, and the ‘stored’ variables update and display correctly.

  • When I click the Collect button on the City View, the ‘stored’ variables are added to the player’s player_resources.wheat global variable (same for gold), then set to 0

  • The ‘stored’ text objects should then show 0

The issue: The ‘stored’ variables are reset to 0 correctly (I checked the Debugger), but the ‘stored’ text objects are flashing and going back to the pre-collect number, and keep going up.

The weird thing is, the first instance of the location object is resetting to 0 with no issues, but any other object instances aren’t resetting.

I’ve got a selected_location global variable, and any actions need to pass the “is this object the selected_location?” condition.

I’ve attached screenshots of my events and the game UI below, any help would be appreciated!

(Please ignore the awful UI, they’re all placeholder assets so I can focus on development)

This is the events list

This is the first instance of the location object’s City Window, after clicking the shopping cart icon (the Collect function). It reset to 0 without any issues.

This is another instance of the location object, and you can see it’s got to 460. I couldn’t get a screenshot of the 460 → 0 → 460 flashing, but hopefully you’ll get the gist!

Edit: realised I named the location objects as city by accident

Perhaps I’ve missed something in your given code, but if the mistake only happens on another instance of the City variable (does it happen if you have more than two?), that means you have to look at the code creating a city (“location”) , or any instanced variables you have for Rome.

The same thing issue (not resetting to 0) happens to all other location instances, so more than two as well.
There’s no code creating the instances, they’re pre-placed in the scene with their own unique variables (name, resource output etc)

Edit: Just realised the possible confusion - I called the objects city instead of location in my post. I’ve now updated the references

This tells me you have a conflict of text changing actions. You need to remove some of them or add conditions to avoid conflicts.