Where is this magnetic rail gun getting its energy? Please watch this youtube video of a magnetic rail gun moving a marble.
So as you already know, Conservation of Energy states that "energy can be neither created nor destroyed, but can only change form". Where is this rail gun getting the energy to move the marble? It looks like it's being created out of thin air. Is it not possible to create a perpetual motion machine by modifying this rail gun? For example, what if a funnel and tube was added that can catch the moving marble, which feeds the marble back to the rail gun to continue the loop? I'm not 100% sure, but I can't imagine any kind of friction will cause this loop to stop.
Thanks!
 A: 
Where is this rail gun getting the energy to move the marble?

The energy comes from the work required to move it from its final location back to the starting location. It is no different than rolling a marble down a hill. You get energy out of rolling it down, but as soon as you try to roll it back up you use all of that energy. You cannot incorporate this into a perpetual motion machine, which has to be restored to its original state.
Also, additional marbles do not change this. Assuming that the marbles are identical then the absolute best that you can do is transfer the first marble’s kinetic energy entirely to the second marble, in which case you are in the same situation as the paragraph above. Assuming instead that the marbles are not identical, then you could get a second (lighter or less magnetic) marble to the top from the energy of the first marble, but that second marble would be unable to get the first marble back up.
Both electromagnetism and gravity conserve energy in this scenario, so there is no clever way around it. You can get energy from this once, but not perpetually. To restore the system to its original state always requires energy. In particular, it requires the person’s hand to do work by pulling the marble away from the final location.
A: A permanent magnet will attract a ferromagnetic object. But when you apply force to remove the object from the magnetic field you will find that there is no net energy gain.
A: There is no deviation from the laws of physics. Magnetic potential energy is the another source of energy apart from gravitational potential energy. As long as magnetic property of the metal exists it will last
