A while is a noun phrase and it means “a period of time”.
Awhile is an adverb and it means “for a time”.
Both words describe a vague length of time. In order to use it correctly follow this tip – if you can replace a word with another noun, such as an hour or a year, you should use the first phrase (a while), and if you can replace the word with another adverb, such as patiently, quietly, etc. then you should use the second word (awhile).
Go play awhile. (Go play quietly).
Go play for a while. (Go play for an hour).
Hope this was helpful. 🙂