Line trace is inconsistent and doesn't work randomly

I’m guessing you’re trying to trace from the head there?

Notice that you’re always tracing to one location.

It’s much better to trace to a fixed distance in front of the head