Auto-translated
So, I need a complex script; I tried to do it myself, but it didn't work. The script should do the following: if a Necropolis castle is captured, you can stand on a tile next to the castle, and a choice will appear: destroy the castle for 30 wood, 30 ore, 10 of each rare resource, and 10,000 gold. If you click "no," nothing happens. If you click "yes," the resources are deducted, the Necropolis castle disappears with a "Holy Word" animation, and a ruined Human castle appears. Next, if you stand on the same tile again, the same choice is offered: build a Human castle for 50 wood and ore and 15 of each rare resource and 20,000 gold. If you click "yes," the ruined castle disappears with the same "Holy Word" animation, and a regular level 1 castle appears. If you don't have enough resources, the action fails, and the ruined castle remains. How can this be implemented?
Added 1 minute ago
I'll mark the tile with a region and put a circle on it so it's visible.