Will a foreclosure on your credit report affect your ability to get student loans in the future?

Absolutely. Your credit score affects all aspects of lending...approval/interest rate etc. If a bank/creditor sees that you have forclosed on a home, they will be less likely to lend you money especially unsecured money like for a student loan.