How to add static mesh to a rig so that i follows its animations?

We are making a 3rd person multiplayer brawler. All the players have the same character, but the differentiating factor is the hat. We have already made the rig for the character. How do I attach the hat to the head so that it follows the head animations? How do I do this without messing up the rig?

You can either add a socket to your skeleton, and attach the hat to that. Or just attach the hat to the bone, (attach to socket node will work both times) just use your bone name inside!

Thank you! It has been more than 3 years and finally I got the answer!