I have to go to court as a witness.

If you got a summons (a paper telling you to go to court) you must go. If your friend asked you to come you can say yes or no. Click here for the witness assistance service website