One of a handful of great episodes from Star Trek's third season, after the show's budget was slashed and it was moved to a miserable time slot, "Spectre of the Gun" is one of those episodes that takes the crew to America's past, specifically, Tombstone, Arizona Territory, Wednesday, October 26, 1881.
Kirk, Spock, McCoy, Scotty, and Chekov don't really travel back in time. They were actually just exploring a strange new world, with a bit of seeking out new life and new civilizations. But the life they encounter – floating, fog enshrouded tentacled brains known as Melkotians – are none too happy about their visit and they do what any good xenophobic telepath would do: they force the crew to re-enact the gunfight at the OK corral, as the losing side.
With McCoy's help, Spock attempts to build a tranquilizer gas grenade. Despite being perfectly constructed – we're talking about Spock after all – it fails to work, leading the Vulcan to conclude that the whole thing an illusion. "Physical reality is consistent with universal laws," says Spock. "Where the laws do not operate, there is no reality."
Or, as another science fiction classic put it, There Is No Spoon.
Spock uses a mind meld to convince the crew that none of what they are experiencing is real, allowing the bullets to pass right through them.