who wrote the script of this episode?
Gene Roddenberry
Writing
The Man Trap" appeared in Gene Roddenberry's original pitch for "Star Trek" as the title of a show with a different plot: 
what is the man trap? The first episode of of the American science fiction television series who are the characters? Professor Robert Crater, his wife Nancy, Captain Kirk, Chief Medical Officer Dr. Leonard McCoy, and Crewman Darnell what is the name of the series? Star Trek
Lee Erwin, George Clayton Johnson, and Gene Roddenberry. George Clayton Johnson George Clayton Johnson.
The Man Trap The Man Trap The Man Trap
Writing Introduction Introduction
 Lee Erwin, who had previously worked on "The Lieutenant" with Roddenberry, was commissioned to produce a treatment; an outline featuring a salt-devouring vampire was handed in on April 8, 1966. Meanwhile, George Clayton Johnson had been assigned a storyline, tentatively titled "Chicago II", in which the crew of the "Enterprise" visit a planet where the culture was that of 1920s mob-era Chicago, which later evolved into """". Johnson was hired after story editor John D. F. Black recommended him to the producers. Johnson decided to use the 1953 science fiction novel "The Syndic" by Cyril M. Kornbluth as the basis for the story. Roddenberry felt that Johnson's treatment did not match his vision for "Star Trek", but did not want to lose him entirely, and asked him to write "The Man Trap". Erwin was paid in full for his version, and given a separate "kill fee" because it would not be used Written by George Clayton Johnson and directed by Marc Daniels, it first aired on September 8, 1966. "The Man Trap" is the first episode of of the American science fiction television series "". Written by George Clayton Johnson and directed by Marc Daniels, it first aired on September 8, 1966.

wiki:14097384
The Man Trap [SEP] Writing
"The Man Trap" appeared in Gene Roddenberry's original pitch for "Star Trek" as the title of a show with a different plot: the crew face several apparitions that are "wish-fulfilment traps which become as real as flesh and blood"; the traps increase in subtlety until the crew struggle to differentiate between apparition and reality. Lee Erwin, who had previously worked on "The Lieutenant" with Roddenberry, was commissioned to produce a treatment; an outline featuring a salt-devouring vampire was handed in on April 8, 1966. Meanwhile, George Clayton Johnson had been assigned a storyline, tentatively titled "Chicago II", in which the crew of the "Enterprise" visit a planet where the culture was that of 1920s mob-era Chicago, which later evolved into """".