If I took you to a party with 20 of your closet friends, gave you your drink of choice, and then tried to teach you a foreign language. Do you think you would learn the language well? How about if I instead taught you that same foreign language in a quiet room with a desk and no distractions? You would likely be more successful learning in that quiet room.
When we teach our canine companions a new behavior, it is helpful to teach them in a non-distracting environment such as your home. Once your dog has successfully learned the new behavior then it is time to gradually add distractions. For example, you can teach the new behavior in your yard or on a walk when there aren’t any people or dogs around. Once your dog can do that then maybe you work with him when there is a person in the distance. Again, gradually adding distractions. It is a process but if you take the time, your dog will be fluent in the language you are teaching!