Were you at the range and was the Glock loaded? There are any number of conditions where it could feel like there was something "loose" inside the weapon. The 1911's we had in the USMC would rattle when you shook them 35 years ago, but they shot every time and generally hit what we aimed at. If the weapon was unloaded and not fully in battery, the barrel itself could have been moving, sometimes you can hold the UNLOADED weapon in one hand and move the slide/barrel assembly slightly, enough to feel motion. Again, what was the condition of the weapon? Let us know and we can diagnose further.