I made this script and it took me a while, but part of it doesn't work. When you place a money gen for the first time then a upgrade it doesn't upgrade until you place another 1. Also when you have more then 1 upgrade in a stack and you place them the last one gets placed instead of canceling the place event
https://pastebin.com/qmh38Vak
https://pastebin.com/qmh38Vak