Gun laws may vary in different states. But what's common among the gun laws in terms of mental health restrictions, is that they conduct background checks on interested purchasers and will deny an application for or revoke a current Firearm Owner’s Identification Card (FOID card) for a person whose mental condition poses a clear and present danger to themselves, to others or to the community. For sure, a person who received inpatient mental health treatment may be denied. The consideration for a person who received outpatient, and not inpatient, mental health treatment is still in question.
You can check a summary of gun laws in your location in this site:
StateMaster - Gun Laws > Prohibited persons (most recent) by state