When a bank forecloses on your home then sometimes you may still owe at least some amount of the mortgage that you took out for the home.
That is if the foreclosure sale doesn't cover the entire cost of the mortgage when they sell your home to someone else.
The mortgage company will take you to court for the foreclosure process and then may be able to go after other assets to pay back the debt owed.
Also having a foreclosure on your home will put a big dent in your credit score which will make it even harder to get another mortgage sometime later down the road.
You should do what you can to avoid foreclosure and work with the bank because foreclosures will harm your credit score and future ability to get new loans and mortgages.