Moving platform that "stops" when it hit something

Thanks for the help! I have two questions

  1. I’m stuck in an infinite loop here:

  1. Also how would (I’m now assuming the player can start the platform) I make the platform stop when a player on the platform collides with something overhead. Here is a picture

26673-collision.png

In this case if the player and platform are both going upwards, and the player collides with something overhead. The platform will return to it’s original poisiton