Autofocus is terrible

Hello. I have a fujixt30ii with a fujixf18-55 and today I did my first paid job, but the autofocus betrayed me. Yes, I was in terrible light conditions, but the camera couldn’t focus properly half of the times even in the rare occasions light was decent. Most of the photos are out of focus, and I’m kinda sad about it. Luckily there wasn’t a lot of expectation by the client, but still. Do you have any suggestions on how to handle the poor autofocus performance? I want to be more prepared next time.