Question: When I design adventures, I often come up with situations where the NPCs could realistically thwart the PCs quickly by sounding an alarm. This is especially common in science fiction settings, where the NPCs have access to surveillance cameras, radars, motion detectors, and other advanced technology. This makes stealthy missions difficult to pull off, because the PCs can be revealed in a matter of seconds if they make even a single mistake.

**How do I keep NPCs from just sounding the alarm right way, without suspending disbelief too much?**

Answer: 
I think the single largest thing you can do to make sure that everything works smoothly is to make sure that everyone is on the same page as far as expectations. You are welcome to have any level of paranoia/security you want, as long as your players understand that going in. If they know it's there, they'll plan for it. If they're unaware for carefully crafted story reasons, it adds to the drama. If they just didn't know, that makes for a huge let down (most of the time).

I played in a sci-fi game where everyone on a planet wore Heart Monitors. One of the other players chose to be a killer robot. He wasn't aware that the moment he killed someone, he was causing an investigation. It escalated to a point where he should have just died to a police manhunt. All this was for smuggling a package that, if caught, would have resulted in a small reprimand. We had no idea of the setting, though. This happened in our first session. We never had a second session.

But, in the retelling, I want to illustrate that the expectations were what ruined that. The robot went in expecting to need to silence any observer. Turns out he made more of a mess by doing so. If he had known about the Heart Monitors, he would have changed tactics. And I think that is the extreme example of an alarm, but even that kind of immediate response could have been handled, with appropriate warning. Spoof the signal (even temporarily), or kill in such a way that the heart keeps going for a short bit, or something. Just make sure that the players know what's *possible* in the setting, let alone what they're facing at the current moment. If they know what's available, and the likelihood they might come across that tech, it's then their job to be prepared.
There are a number of approaches you can take, depending on the specific campaign.

**1. Remember that many places don't have an alarm to hit.** A lot of interesting targets will not have an alarm to hit, or will only have a very basic one that requires some human to trigger it manually. Many places will not have one due to cost and complacency. Others, especially in a cloak-and-dagger type game, will not have one precisely because they have something to keep secret and will not have or do anything that can betray what is going on inside or attract outside attention. And of course if it is something along the lines of a "panic button", then all the PCs have to do is either avoid detection by humans or take the person down before they can hit the button. That type of alarm will make the stakes of being detected higher, but not change any fundamentals.

**2. Preparation** As lorimer mentioned, dealing with the alarm can be part of the game. If the PCs know to expect an alarm they can find some gadget (in sci-fi) or spell or amulet (in fantasty) that lets them get past it. Or they can find some way to disable it ahead of time. Or they can use social engineering to avoid the issues (of course the gaurds will politely turn off the alarm for the nice repairman, people can be bribed to disable them, etc).

**3. Does the alarm actually matter?** Sometimes an alarm can go off and it just doesn't matter, besides adding flavor. If, say, the alarm just calls out to normal law enforcement the response time could be measured in several minutes (possibly more if there is a big event tying up law enforcement's attention or this is a dystopian future where law enforcement is stretched past the breaking point...) The PCs might be able to ignore the alarm, do their thing, and get out before the cavalry arrives, the alarm just adds some urgency.

Even better, if the PCs have enough information, they might be able to use the alarms to their advantage. If the PCs have one team deliberately trip an alarm somewhere, it just might pull security away from their actual target while they go in. Even if they unintentionally trip a second alarm, they might have some time and face a reduced security response because of the first alarm.