Sales tax savings by trading in vehicle to same dealership as where I purchase?

In Florida, my understanding is that if I buy a $50k car, and sell the same dealership a car worth $40k car, I only pay sales tax on the difference ($10k).

How does this work for a lease, where sales tax is calculated on only the monthly payments?

In the above example, would I still save 40k of sales tax on a 50k car, or would it be less?

Haven’t been able to find a good source for this on Google…

the trade-in equity on your car goes against the cap cost reduction on which there is no tax as long as it can be considered one transaction For example, it does not apply if you turn in a lease which the dealer purchases from the finance company and you lease another car, since the lease turn in is a separate transaction.