You went to your friends and after a while she left the room and her cat just suddenly attacked you or at least tried to what do you do next time you go over because im really scared?

You should try to earn its trust. Next time you go to your friends house, ask your friend if you can try to hold the cat. If she says "No, the cat doesn't like to be picked up by strangers," ask if you can pet it. A cat will feel more happy if you try to pet it while its curled up.

A cat will feel better if you crawl to get near it. This gives the cat a sense of authority, because your eyes are lower than his. As you get nearer, hold your hand out as if you had something in it, because then curiosity will overcome the cat and it will sniff your hand(it might help if you actually had something in your hand, like food).

If your friend has cat toys, or even some string, playing with the cat will help you gain trust with it. Twirl the string above his head and the cat will probably swat at it, no matter who is holding the string.

If this doesn't help, then the cat just doesn't like you. It might feel like you are stealing its humans from him. If this advice doesn't help next time you go to your friends house, stay away from the cat in the future.