So it will coast, but then when you try to pedal it does not engage? Or do you mean then when you no longer have downward pressure on the back pedal, the pedals spin?
If the former, you need a new freewheel. If the latter, you need new grease or something. I had that happen once, and a tech at my LBS sprayed something into the freewheel, spun it a few times with a chain wrench, and it was good for another few years.