When creating your own mods, you should do so in the freeplay modding area (play < Mods)
Just remember there should be one function with the title 'main' lowercase otherwise it won't run. It also shouldn't have any blocks floating outside functions or any blocks that are missing blocks.
What does the error say exactly? Could you post a screenshot? Don't forget to press the load starter code button or load prompt button if there is one.
The book's a little outdated by now; if you're having trouble finding any badges let me know, or can't run mods in the simulator.