The screenplay was written by Wright and Pegg in eight weeks. They were inspired by films including "Night of the Living Dead" (1968) and "Dawn of the Dead" (1978), as well as "Raising Arizona" (1987), "Back to the Future" (1985) and "The Birds" (1963). The actors met three weeks before filming began for read-throughs, where they also made changes to the script. According to Pegg, the script has a set structure, with certain lines and actions being repeated throughout the film, making improvisation harder. Only two scenes were improvised: when Ed begins to describe the people at the pub and when Shaun offers their associates some peanuts.