This is quite a tricky question because, in most cases, it is cheaper to repair the air conditioner or heater than to replace it, but there are nuances. Before you decide whether to replace or repair your HVAC system, answer a few questions.
How old is my current HVAC system ?
How often have I had it repaired before?
Have my electric bills increased?
If your HVAC system is more than 10 years old, you have already repeatedly repaired it, and electricity bills increase since the conditioner does not cope and works longer. Then replacement will be the best option, in the long run, you will spend less money by changing the HVAC system once than by repairing it several times and, as a result replacing it anyway.
If it is a one-time failure, then most of the parts in the HVAC system can be replaced, and it will continue to serve you well.