How would i make a train system like in PBCC

How would i make a train system like in PBCC. So if you are hit by the train you die. If you collide with another train your train and the other train breaks (or explodes). Is there any way to do this? And you can switch rails. For those who dont know what PBCC is you can join on me im currently playing it.

if you use a touched event you can use it to assign actions.