I made a pathfinding script for an NPC. I followed the Pathfinding tutorial and made sure to follow every step precisely. When I finished it, it worked perfectly fine, it did everything I wanted it to. Then I hopped off Studio for the night.
When I went back on this morning and launched the NPC, it all of the sudden won’t bother going around obstacles and walks straight to the target. I didn’t tamper with the script or NPC at all, I just closed my laptop for the night. I’ve tried digging through the script and output looking for errors, but none were there.
I am very sorry if I overlooked an obvious thing, but I just didn’t see anything. Help would be greatly appreciated. Here is the script:
local PathfindingService = game:GetService("PathfindingService")
local motivator = game.Workspace.motivator
local humanoid = motivator.Humanoid
local destination = game.Workspace.GreenFlag
local path = PathfindingService:CreatePath()
path:ComputeAsync(motivator.HumanoidRootPart.Position,
destination.PrimaryPart.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