I have heard stories such as
A wealthy man felt like abandoning his Judaism and went to the kotel to 'say his goodbyes'. There he saw a chasid davening with such fervor and tears that the wealthy man decided not only to continue being a torah Jew but also to donate millions of dollars to charity.
That type of story usually ends with "and when the chasid gets up to Heaven, they will show him the merit he received for giving millions of dollars to tzedaka. But, 'I never did any such thing,' protests the chasid. 'You are receiving this merit for inspiring another person,' is the response.
My question is, is this true? If, through no intent of my own, someone sees me or something I have done and is inspired to do good themselves, do I get the credit? If so, why (after all, I haven't actually done the specific action)? And, does this work in the reverse (can someone be punished for causing someone to sin by modeling bad behavior)?