Familiarize yourself with the comedy genre. Watch comedic movies and TV sitcoms, read humorous essays, attend comedy shows, and read magazine and newspaper cartoons.
If something cracks you up, ask yourself why you think it's funny. Is it because the situation itself is ludicrous (i.e., the Queen of England using public transit)? A domestic squabble that you can relate to on a personal level? Or a sophisticated humor that relies on a familiarity with classic literature or pop culture? As a general rule, the kind of comedic set-up that appeal to you will be the kind of humor youl feel the most comfortable writing.
Understand your audience. The younger, less sophisticated and less educated your target demographic, the more the humor is going to revolve around visual elements, slapstick, and repetitive jokes. Think about the simplicity of things that crack young children up at a birthday party. For example, kids love to see people falling down, getting smacked in the head with various objects, and being the object of goofy pranks. In contrast, an audience of college educated professionals is going to derive more entertainment from clever conversations, snappy wordplay, topical references (i.e., current politics), parodies/spoofs of blockbuster films, sarcastic observations about human foibles, and abstract "what if" concepts.
Incorporate conflict into your comedy plot. Although we typically think of conflict as being associated with feelings of anger and drama, a funny script revolves around the obstacles that stand in the way of a person getting what he wants (i.e., a date, a promotion, a better parking spot, etc.). Keep the conflict simple. However, make sure it is something your target audience can easily relate to within the context of their own lives, interests and occupations. Escalate the conflict with each turn. For example, a bumbling handyman's attempt at a minor repair results in an entire house collapsing.
Keep the setting, props and number of necessary characters modest. If a comedic scene is going to call for an extremely expensive set to deliver a funny one-liner, the script is probably not going to be picked up by a producer. If your original draft of the material utilizes a pricey backdrop, look carefully at whether the backdrop is really essential to the delivery of the verbal or visual humor. For variety, choose settings that are completely contradictory to the dialogue and characters (i.e., Madame Curie trying to conduct her experiments in an ice cream parlor).
Brainstorm with a group of like-minded writers. Toss lots of silly ideas, characters and jokes into the mix, then go back and see which ones strike the funniest chord and can be developed, exaggerated, and manipulated into a sustainable storyline.
Cast the players in your head when you start writing comedy lines. This often makes the writing flow much easier because you already have a familiarity with how a particular actor talks and moves. The only cautionary note here, of course, is to be able to differentiate between an actor who can deliver a funny line and an actor who is naturally funny. Download a free copy of comedy scripts from a websites like www.scriptdude.com. Compare the way a funny line was written versus how it was actually delivered.
Read your comedy scenes out loud. Better yet, recruit friends to read the lines aloud for you. This is a good way to identify whether certain word combinations are funnier than others or the pacing is appropriate.