I am writing a code for the NPC to follow and potentially attack the player, but an error appears. In the output, it says “Attempt to Index nil with ‘Position’”
Here’s my script and the output:
I used print(“E”) function to identify errors, and it seems to get stuck before the 2nd if statement. If I remove the or in the first if statement and replace it with and, the script loops a lot between lines 9 and 12.
If I do, the NPC does nothing, and the script loops between lines 9 and 12, which is between the variables human and torso
The Loop lasts for a little bit then continues the script, but nothing happens to the NPC