You should only get a car loan if you actually need the car. Taking on tons of extra debt just to boost your credit score a few points isn’t ideal.
However, if you want to improve your credit mix by getting an installment loan—such as a car loan—and you need the car, it might be a solid move. Keep in mind, your credit score will drop by about five to 10 points from a hard inquiry and then an additional 10 to 20 points from opening the loan, but this hit is only temporary.
If you continue to make on-time payments to your car loan, you should see your score steadily rise over time. If you have any extra cash, pay off other high-interest debt to further boost your credit score.