Make AI's/NPC's (Non-Player Characters) move with MoveTo

I am trying to make an NPC move with MoveTo, this works for the players in my game (with the Humanoid), but not for NPC’s (also with the Humanoid)

game.Workspace:FindFirstChild("AwayAIGoalie").Humanoid:MoveTo(Vector3.new(five, 147.188, six))

I have tested this and the variables five and six do work with the Character’s MoveTo but not Humanoid’s is there a way to fix this or is there just a different mover i can use?

1 Like

have you attempted to use a loop to move the character there. By the way are you trying to get it to move slowly or teleport because :moveto teleports your character

:MoveTo does not teleport a character when used in combination with a PathFinding computed path.

See this.

local Humanoid = script.Parent.Humanoid
local Folder = game.Workspace.Points -- This is the folder with the parts the NPC will move to (Change it to player etc. if u want it to move to the player)

local loop = true -- Choose if u want it to loop

if loop then
    while true do
        for i, v in pairs(Folder:GetChildren()) do
            Humanoid:MoveTo(Folder:FindFirstChild(i).Position)
            Humanoid.MoveToFinished:Wait()
        end
    end
else
    for i, v in pairs(Folder:GetChildren()) do
        Humanoid:MoveTo(Folder:FindFirstChild(i).Position)
        Humanoid.MoveToFinished:Wait()
    end
end

Hope this helps and make sure to mark this as a solution if it did!

workspace:FindFirstChild("NPC"):WaitForChild("Humanoid"):MoveTo(workspace.point.Position)

or

workspace:FindFirstChild("NPC"):WaitForChild("Humanoid"):MoveTo(Vector3.new(five, 147.188, six))

Add a break to the loop after the “pairs”

if loop == false then
    break
end

it just won’t loop more than once, so urs ain’t needed