First of all you need to find out if the loan is assumable. I believe most bank loans in last 15-20 years and maybe longer are not assumable. If it is assumable, to do this right you need to establish a reasonable number for the value of the home at the time of the transfer. From that point it gets complicated and can go different ways depending on how the current value compares to what you paid and the loan balance. I suggest you get some professional help and not from someone that just does taxes. You need a lawyer and maybe a CPA or at least a lawyer with experience in real-estate transactions and or related tax issues. TT is NOT the place to get these answers.
However for the buyer (person assuming the loan) it will be simpler once the transaction is made. Their basis will be whatever value is established or the loan balance and their gain when they sell will be determined by that.