Theres already a really good tutorial on that made by EgoMoose, its open sourced too.
You can edit it to your likings.
By the way, If your new to scripting, I would recommend you to learn the basics and stuff, not jump right into the advanced stuff.