It was many factors that saved him. The people raising the alarm near the shooter, who rushed the shot, also probably saved Trump. If he had gone undetected and/or been more experienced, Trump would have been a dead duck.