When to take a pregnancy test?

I want to take a pregnancy test but I don't know when to take it to get the best results? sorry if that sounds dumb I just don't know exactly how to word this like how long should I wait after unprotected sex to take a test?