It can pay to work for free — if you do it right.

This week, Tesla announced a new 10-year compensation plan for its chief executive Elon Musk, and it could mean that Musk gets paid nothing for his work at the company — or billions. The plan ties Musk’s pay to aggressive targets related to company performance. If he meets them, he gets paid; if he doesn’t meet any of them, he could walk away with nothing.

“Elon will receive no guaranteed compensation of any kind — no salary, no cash bonuses, and no equity that vests simply by the passage of time,” Tesla announced. “Instead, Elon’s only compensation will be a 100% at-risk performance award, which ensures that he will be compensated only if Tesla and all of its shareholders do extraordinarily well,” the company said.

While Musk — who is worth an estimated $20 billion — won’t suffer too much if he doesn’t get a huge payout from Tesla, the rest of us likely would take a financial hit if we worked for free. So Moneyish asked experts: When should you work for free — and when should you not? And how do you do it smartly?

The questions to ask yourself before you work for free are these, says New York City-based success strategist Carlota Zimmerman: “What will it benefit you? And then, are the benefits greater than a paycheck?”

There are some savvy reasons to work for free. Use it as a way to help yourself standout from other job candidates — like doing a one-off project for a company where you want a job, says Niteesha Gupte. a leadership and career coach at Ama La Vida. Or to do it in the hopes of getting a reference for a job down the line or exposure to the right people in your industry, says executive coach Marc Dorio; or do it “when it provides valuable exposure of your skills and services to an industry or community that you are targeting,” says Gupte.

Perhaps the No. 1 reason to work for free is to gain experience and contacts in a field, so you can land a paying job in that field down the road. You can do this by taking an unpaid internship, doing a one-off project or volunteering with the organization, for example.

To do this in a smart way, ensure that the unpaid gig is, in fact, a way to achieve the experience you need to land that future job. So, Call to Career founder Cheryl Palmer suggests working for an organization that: is likely to have openings in the near future, can put you in a position to make contacts who can help you in your job search down the line, and can offer you work that will give you new skills, versus say fetching coffee and stuffing envelopes. Palmer says that you can figure this out if you meet with someone from the company by asking about what work you will be doing and who you will work for. “Then offer to follow up with a written proposal of what you will be doing based on the agreement that you made,” she adds. Also, be sure to “ask who you will be working with as well as whether or not they have ever hired interns or volunteers,” Palmer adds.

When working for free, “be aware of not being taken advantage of,” warns executive coach Nancy Halperin, principal at KNH Associates. Zimmerman recommends that you consider setting limits on how, when and why you work. Talk to your boss about how you will need to balance your paid work with this unpaid work, and do things like set hours of work, layout the types of tasks you will do, and more. Also, set at timeline for how long you’ll be doing the free work, Palmer adds.“You might say, ‘But isn’t that going to destroy the opportunity, the reason I’m slaving for free?’ Probably not. Someone who takes advantage of your free labor doesn’t value it,” adds Zimmerman. Whatever your reasons, look at your long-term goals and see if working for free can help you reach them.

Even if you work for free for all the “right” reasons, it may never wind up leading somewhere. So learn when to say no. “Evaluate every non-paying opportunity carefully, identifying how it will help you in the future. If it doesn’t, say no,” says Andy Bailey, CEO of Petra Coach. One example of when to say no: “If you’ve been working for free in said field for a few years, and people are still trying to pay you in experience, okay now you have to take a stand, and make it clear that yes, experience is a wonderful thing, but at the end of the month, you can’t pay the rent in experience,” says Zimmerman.

It’s also important that you don’t just take a job that doesn’t pay and doesn’t move your towards your goals just to have something on your resume: “If it doesn’t provide any benefit to you and your career, hold out for an opportunity that does,” says Gupte. And don’t get guilted into doing your work for free just because a company says they can’t afford your services, she says.