I'm scared of going to a psychiatrist because I've seen people in court getting backlashes for things they said to the psychiatrist. What should I do?

Get help if needed. Doctor/patient relationship is bound to confidentiality meaning everything said is confidential with few exceptions( danger to self/others, court order). Is unclear what you meant by " backlashes" but if you need to get help you can discuss your concerns in details with the psychiatrist before accepting or not to proceed with the psychiatric evaluation.
Dilema. Its a legitimate concern, psychiatrists and psychologists should go over cinfidentialit limits with a new patient. If there is immediate danger to self or others, child abuse, or if you become involved in civil or criminal proceedings where you claim injury or a psychological defense, courts can order release of normally confidential information. There r risks, and risks of not getting help.
Confidentiality. Unless you're seeing the psychiatrist for a court-ordered forensic evaluation, or you think attorneys are likely to subpoena your medical records, what you tell the psychiatrist is confidential. Forensic interviews happen in criminal investigations. There, the psychiatrist is working for the court -- and isn't your treating physician. You can ask the psychiatrist about his/her role with you.
U should not be scar. Take u time , and any thing u don't feel comfortable about u don't need to say initially until u get used to u psychiatrist. But remember in realty he or she r here to help you.