How do you make the players head a ragdoll?

Currently I’m making a game and I want the players head to start flopping around when the u key is pressed because it would be hilarious. I’m am a complete newbie when it comes to scripting with only like 4 hours of practice and I’ve tried following some examples on the internet but they only work when the character dies. I would like this to keep the body intact with only the head being a rag doll using the players avatar.