Pathfinding Player AI issue with primary part

  1. I am trying to achieve a pathfinding player, that would walk to certain areas when designated.

  2. Code:

wait (11)
local zombie = game.Workspace.Chloe
local humanoid = zombie.Humanoid
local pointA = game.Workspace.Tents
humanoid:MoveTo(pointA.PrimaryPart.Position)

Error: 13:48:34.900 - Workspace.Chloe.Script:5: attempt to index field ‘PrimaryPart’ (a nil value)

3.I have tried changing the primary part and changing humanoid but nothing worked, I tried looking for others with this issue but couldn’t find any.

  1. Are you sure that pointA has a primary part, or is a class that can have a primary part, a Model, specifically?
    Try printing pointA.PrimaryPart right before the humanoid:MoveTo call.
wait (11)
local zombie = game.Workspace.Chloe
local humanoid = zombie.Humanoid
local pointA = game.Workspace.Tents

print(pointA.PrimaryPart)

humanoid:MoveTo(pointA.PrimaryPart.Position)
How I formatted this code block

You can use three backticks or three squigglies on both sides of your code to create a code block:

Input:
```
--code here
```

This works too:
~~~
--code here
~~~


Output:

--code here

Just realized where it’s going to, needs a primary part, thanks for the help!

1 Like