You aren't trading for a player, you are trading for a massive cash savings.
To repeat what I've said elsewhere, let's say the lux is coming in so that we go $1m over.
We pay $1m tax on that. We loose 4-5m in benefits paid to teams under the cap. We pay Troy his $12m. So trading him only for the 29th pick gets you maybe Booker or Poindexter, still a solid player and saves you 16-18m bucks.
The space away from the lux tax means you can take a salary increase on another trade if need be without going over the tax.
And if you buyout Z you likely get minor savings, maybe 500K perhaps.
Or keep him and let him take the team to where? This isn't the NBA 3 years ago, this is the new, declining cap numbers NBA where every team values salary space MORE than talent.