Overview
"Spectre of the Gun" is the sixth episode of the third season of the American science fiction television series Star Trek. Written by the series' former showrunner, Gene L. Coon (under the pseudonym of Lee Cronin), and directed by Vincent McEveety, it was first broadcast on October 25, 1968.
In the episode, having been found trespassing into Melkotian space, Captain Kirk and members of his crew are sent to die in a re-enactment of the Gunfight at the O.K. Corral.
Plot
The Federation starship Enterprise has been directed to make contact with a reclusive species known as the Melkotians. As they approach the Melkotians' planet, they encounter a probe carrying a warning for them to stay away. Crewmembers hear the warning in their native languages, suggesting that the Melkotians are telepaths. Despite First Officer Spock's warnings about the formidableness of telepaths, Captain Kirk orders the ship to remain on course. Once in orbit, Kirk, Spock, Chief Engineer Scott, Chief Medical Officer Dr. McCoy, and Navigator Ensign Chekov transport to the surface.
They are met by a Melkotian emissary, who declares that they have been condemned to death for trespassing. The landing party then find themselves in an abstract landscape that resembles an Old Western town, though many buildings are only simple wooden facades. Furthermore, they find their phasers have been changed into six-shooters, and they cannot contact the Enterprise.
From Wikipedia (CC BY-SA 4.0).