NPC won't pathfind in certain parts of the map

I made a really simple pathfinding script for my NPC. It works fine in some parts of the map but not in others. I checked and there are no walls or anything blocking it, it is a completely open path. Here is my script:

local PathfindingService = game:GetService("PathfindingService")

local motivator = game.Workspace.motivator
local humanoid = motivator.Humanoid
local destination = game.Workspace.GreenFlag.PrimaryPart

local path = PathfindingService:CreatePath()

path:ComputeAsync(motivator.HumanoidRootPart.Position, destination.Position)

local waypoints = path:GetWaypoints()

for _, waypoint in pairs(waypoints) do
    local part = Instance.new("Part", game.Workspace)
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(.6,.6,.6)
    part.Position = waypoint.Position
    part.Anchored = true
    part.CanCollide = false

    humanoid:MoveTo(waypoint.Position)
    humanoid.MoveToFinished:Wait()
end

There seems to be no errors except these really weird ones below:

output

I don’t know what to do. Any help would be greatly appreciated!

1 Like

Return you a 403 (Not allowed) and try to change
local part = Instance.new("Part", game.Workspace)
to

local part = Instance.new("Part")
part.Parent = workspace
2 Likes

I’m sorry, I’m not sure what this means. I’m still new to scripting. Also, when I changed the other lines of code with the part, the parts don’t show up for some reason.

I think you are doing something wrong because it works very well for me
the problem must be with the thing that changes the position

Might it be your variable name for when you create the path?

By chance, do you have an admin script in your game? Admin will have caused the errors in your output.

I know from past experience with free admin scripts that come from the toolbox

I do have an admin script, I use Khol’s Admin

That is absolutely why. It always gives me that error when I use Kohl’s admin.

I removed the admin, it works a little better, but it doesn’t work completely. It doesn’t work in some parts of the map still.

That just gets rid of the error.

Try making your created path variable to Path instead of path

That did not make it work either.

At this point I have no idea how to really fix your problem. I am glad that I could help clear up the errors in your output because if you tried to use datastores, you wouldn’t be able to because of Kohl’s admin screwing around with your game.

Thank you for trying to help. I’m sure I’ll figure it out eventually.