Lin-Manuel Miranda of “Hamilton” performs at the Tony Awards in June in New York. (Evan Agostini/Invision/AP)

Lin-Manuel Miranda is doing pretty well for himself these days.

But when the creator of the Tony-winning musical “Hamilton” was in his 20s, he made a financial mistake that a lot of people in their 20s and 30s might also be making today. The author and actor admitted in a recent interview with Morgan Stanley that he was so cautious about spending and taking on debt when he was starting out that he didn’t get his first credit card until he was 28.

By then, Miranda had written and starred in “In the Heights,” his first show on Broadway, and he “had enough money in the bank” when he tried to buy his first apartment, he said. But that money wasn’t enough to overcome his short credit history. As a result, Miranda had to ask his father to co-sign on his mortgage, according to the interview.

“There is so much I wish I knew about money when I was first starting out my adult life, but in particular, the importance of building good credit,” said Miranda, 37.

His experience shows one of the major challenges some people face when it comes to accessing loans: It often takes credit to get credit.

In addition to looking at factors such as income, lenders typically like to see that you have a steady track record of paying your bills on time before they approve you for a loan. Opening a credit card can be one of the easiest ways to build that payment history because the monthly loan payments are tracked on a consumer’s credit report, says Matt Schulz, senior industry analyst for CreditCards.com.

But like Miranda, many millennials who are nervous about taking on too much debt are shying away from plastic. Some 49 percent of millennials surveyed in January said they do not have a credit card, according to CreditCards.com. Some young workers may be nervous about borrowing after graduating into a tough job market and struggling to pay back their student loans, Schulz said.

One option is to start building credit by using a secured credit card, which requires you to provide a few hundred dollars up front as collateral, Schulz says. Typically, you would receive a credit card with a spending limit up to the amount of money you provide. So say you put down $500, you would be able to charge up to $500 on your credit card. The cards provide an actual credit line and can be used for everyday purchases, he says.

You may lose your cash deposit if you fall behind on payments. But if you pay your bill on time each month, that steady track record may help you to qualify for other loans in the future, including a traditional credit card, Schulz says.

Most people will have a decent credit history if they follow a few key rules, Schulz says.

Pay your bills on time — every bill, every month, he says. Keep your balances low, preferably by paying off your credit cards in full each month so that you can minimize interest charges. And don’t apply for credit too often, since those applications can ding your credit score, he says.

“If you do those things and keep doing them over time, your credit is going to be fine,” Schulz says.

Read more:

Uber rides, fancy lounges and other ways credit cards are fighting to win your business

Never had a credit card before? Here are your options.

The right way to use your credit cards if you need to boost your credit score soon