Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I'm new to pathfinding, how can I make this script move my NPCs?

if AttackPathFinding == true then --AttackPathFinding is a parameter
                print('AttackPathFinding is true')
                local PFS = game:GetService("PathfindingService")
                local ClonedHumanoid = ToClone:FindFirstChild("Humanoid")
                local Target = game.Workspace.Water --Placeholder
                
                local AttackPath = PFS:CreatePath()
                AttackPath:ComputeAsync(ToClone.HumanoidRootPart.Position,Target.Position)
                local AttackWaypoints = AttackPath:GetWaypoints()
            
                local MoveNPC =    coroutine.create(function()
                    for _,MovementWaypoints in pairs(AttackWaypoints) do
                        ClonedHumanoid:MoveTo(MovementWaypoints.Position)
                        print('Moved NPC')
                        wait(0.05)
                    end
                end)
                coroutine.resume(MoveNPC)
            end

All of the prints work, the NPC's just won't move, the HumanoidRootPart that they are cloned from is Unanchored, and they simply won't move.

1 answer

Nevermind, CanCollide was true on the HumanoidRootPart

This discussion is preserved as it was. New answers, comments, and votes are closed.