One of the best skills a GM / DM can learn for Tabletop gaming is the ability to improvise during a game. Frequently the players will come up with some plan or idea that you never even considered, and it can throw off your entire plan when it happens. So how do you deal with these situations?
Well, you can freeze and lose the flow of the game as many new DMs do. This is a normal reaction and even experienced GMs deal with it. This however is not an effective reaction generally. Another option is to tell the players “No that’s not going to work because *reason*” but that takes away player agency, and can feel like you are forcing the players down a specific path.
What you need to be able to do is think on the fly and improvise a new solution that will fit your story, and let the players do what they want. And for that, you need to be able to improvise and keep up the pace of the game. And let me be honest, this is a hard skill to master. I did a video a while back on my Top 3 GM Skills and this post sort of expands on that vid.
First and foremost, you need to be able to think on your feet and react quickly, and come up with a way for the players to move forward using their idea while also making it seem like you had it planned all along. And there are some things you can do to help both your speaking ability to make it seem natural, and also your emergency prep stuff. A good book, by the way, that you may want to check out is the Lazy DMs Guide by Sly Flourish & Its sequel, both of which have tons of good advice for how to do low prep high improv games that let your players guide things while you sit back and adjust as needed. Also the sequel even has sweet tools you can use for quick creation of monsters and such.
As far as dealing with the contents of an adventure going off the rails (such as the players going East when you intended for em to go West) you may want to consider a set of index cards with emergency encounters on them. These can help you easily plop down a fight, a dungeon, whatever, when the situation calls for it. You also should be willing to adjust where the players find the item or clue they need for your story. If you meant for them to meet a lone traveler on the road who would help them, perhaps instead now they end up in this crypt and find their corpse with a note on it, thus giving the players the intended bread crumb. Things like that. Always, ALWAYS be willing to adjust your plans to fit your players intentions, and you can slowly hopefully guide them back on the path you planned. Hell, think of yourself as a god of the world if need be, and be willing to move places and locations wholesale. If the players did not have foreknowledge of a things location, how would they know that you moved the Black Forest from a mountain valley in the North and dropped it in front of them in the west? They wouldn’t! The world, for you, is malleable, never forget that.
As far as improving your ability to make this all seem like it was intended all along, one of my best tips is to practice speaking. As crazy as it sounds, getting good at speaking takes practice, and one of ways I personally practice is to rehearse everywhere. Come up with imaginary situations in your head and start holding a one sided conversation in the shower, on your commute, ect. Basically talk to yourself and imagine how the other party would react in your mind, and then respond to that reaction. Change the reactions as you need to and practice dealing with sudden shifts. Imagine what your players MIGHT do (you should have a good idea of how they react to things) to play out scenarios in your head, and say out loud your responses.
Yes, it’s a little silly, but it works really well once you get the hang of it. Additionally, just sheer experience will improve your speaking ability alone. The more you play the game, the better you will get at doing these things. And don’t worry too much about messing things up, because its your game! If you mess something up and no one catches it, was it ever a mistake? I say no.
It was planned alllllll along.