A couple of times now I've seen people get depressed when the thing they're working on doesn't work out the way they hoped. Or perhaps they're injured and are watching their "team" do work without them and feel bad for not being able to do anything. For those people I have a very simple message: You are worth far more than just the work you do.
What is the value of a smile or a laugh? It is something that can cheer up your whole day. What is the value of a good conversation? It is something that can make you re-evaluate your world view. What is the value of a drink at the pub one evening? It is something that keeps you from from being lonely. What is the value of a relationship? The list goes on and on. There are so many things that a person can provide that nothing else can - and it's nothing to do with work you've done or work you can do in future!
So if a project has just been ended because it failed, or if you're currently sitting on the sidelines: don't give up, don't think of yourself as worthless. Your team, your colleagues and your friends don't think less of you because of it.