Making a tower defense, and when I set it to target the first enemy it doesn’t work well, sometimes feels like it’s shooting at random enemies
the problem is that you are checking the distance to the end, but not to the next checkpoint of that mob. Check for the mob’s distance from the next checkpoint. Lastly, you also need to check whether it is closer than the current closest you have found.
it says “nextcheckpoint”
and I already did that
Ah, my bad. I was doing something, so sorry for not replying. But now that I look at the script again, it seems like you only check if the checkpoint the mob is on is greater than or equal to the current best/farthest checkpoint. You then checked whether the distance was less than the best distance but never checked whether the best checkpoint from that time was before that mob’s checkpoint. A fix is to set it to that mob if its current checkpoint is greater than the best waypoint.