No you should not be taking out that loan money. You should listen to your bankruptcy attorney on this point. When you file for bankruptcy, they will make you pay back your creditors will available funds that you have. However, retirement accounts are safe from bankruptcy seizures. So if you take out money from your retirement account, even if you use it to pay off student loans, they can seize that money and force you to give them the money instead. They can void any transactions.
Even after filing for bankruptcy, you should not be taking money or making loans of your 401k to pay down anything. Your 401k is used for retirement and unless you're retiring, you should not be using that money. There are so many reasons, tax and otherwise, that you should not be doing this that it would take a long time to list here. Don't do it. You will need to pay off your student loan debt, but do it the traditional way. Do it the right way. Save money and pay it off. Your 401k is not a savings account for you to dip into and it is not an emergency fund.
The money you have validly contributed to a validly created 401K Plan is protected in bankruptcy.
I recommend that you follow the advice of your lawyer about withdrawing money. Your lawyer is on the spot, and has had the benefit of interviewing you and evaluating your case. It is hard to second guess that via a question sent on the Internet.
Call the student loan office. Chances are good they will work something out for you.
I do hope that you get all this behind you soon, and have a great new year.