Hello sodded,
Thanks for asking your question here in the Apple Support Communities. If your Mac restarts unexpectedly, an error known as a “kernel panic” occurred. After the restart, you may see a message that your computer restarted because of a problem. The most likely cause is faulty software. A kernel panic can also be caused by damaged or incompatible hardware, including external devices attached to your Mac. I understand how important it is to have the sleep/wake function working properly on my personal Mac at home. Here are the things I recommend you check for this.
As always, we want to do is ensure the data on your Mac is safe. You will need to use Time Machine to make a backup to an external hard drive. The recommendation is to use an external hard drive two times the size of your internal hard drive. Use this article for help making a backup: Use Time Machine to back up or restore your Mac.
Once you have a backup and you know your data is safe, go ahead and eject any and all external hardware connected to the Mac. This will include any external hard drives, displays, thumb drives, flash drives, USB hubs, external keyboards, mouse or trackpad devices, etc. This includes even devices connected by bluetooth. If this is a portable computer, you can remove everything. If it is a desktop computer, the only things you should have connected is the power cable, one Apple keyboard, and one Apple magic mouse or magic trackpad connected via USB or bluetooth. Test the computer by letting it go to sleep, or by manually putting it to sleep by clicking the Apple, then clicking sleep. Also, test if the issue happens with the charging cable plugged in, or not, if applicable. If the issue is caused by the Apple official charger, please have the computer and charger checked at an Apple Authorized Service Provider or an Apple Retail Store. If it is any other device connected to the Mac causing the issue, please contact the manufacturer of that device to see if there are any updates to the firmware or drivers to allow the device to work properly with the new operating system.
If everything is disconnected and you are still experiencing the issue when the Mac goes to sleep, please check this article: OS X: When your computer spontaneously restarts or displays "Your computer restarted because of a problem.". This article is long, but it is very informative because it has so much info to help you isolate and resolve this issue. If you have removed all external hardware and other items, then you do not need to go through the section titled "Hardware troubleshooting".
Thanks again and have a great rest of your day.