Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make npc walk to waypoints?

Asked by 1 year ago

Hello, I want to make an npc walk to waypoints but the problem is that there are so many waypoints that typing them all out individually like this would take a long time

Humanoid:MoveTo(Waypoint1)
Humanoid:MoveTo(Waypoint2)
Humanoid:MoveTo(Waypoint3)

Is there any way i could just make npc walk to another waypoint without doing what i did earlier?

0
I'd do it with a loop that counts down the number of waypoints until it's 0. flireferret 26 — 1y

2 answers

Log in to vote
1
Answered by
commag 228 Moderation Voter
1 year ago
local waypoints = {waypoint1, waypoint2, waypoint3}

for i, v in pairs(waypoints) do
    Humanoid:MoveTo(v)
    Humanoid.MoveToFinished:Wait()
end
Ad
Log in to vote
0
Answered by 1 year ago

You can wait until it finished walking to a waypoint by using Humanoid.MoveToFinished:Wait() for every Humanoid:MoveTo()

Humanoid:MoveTo(Waypoint1)
Humanoid.MoveToFinished:Wait()
Humanoid:MoveTo(Waypoint2)
Humanoid.MoveToFinished:Wait()
Humanoid:MoveTo(Waypoint3)
Humanoid.MoveToFinished:Wait()
0
Don't believe that's what he's asking. He wants to prevent having to type them individually. xInfinityBear 1777 — 1y

Answer this question