in your sensing scripts for the terrain, simlpy have one with touching terrain 0 or 1 or 2 or 3- seperate scripts conflict with each other- one sets the variable to one, the other to two. look at this correction.