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

MoveTo() only moves NPC some of the way?

Asked by 8 years ago

So, I'm making a zombie walk from its spawn position to a specific coordinate via MoveTo(). However, the zombie only walks like 5 feet from its original position then stops. It walks in the right direction, as if it was going to the position, but it just randomly stops 5 feet from its spawn point everytime. And yes, I've moved the spawn point around, but no matter where I put it, the zombie always stops 5 feet from its spawn. Here's my code (its very simple).

script.Parent.Humanoid:MoveTo(Vector3.new(My Coordinate)

Some things I should mention: I'm using an already coded zombie AI. The zombie AI thats always recommended eveytime you open up toolbox, thats the Zombie I'm using. I've stripped the Zombie of all its AI scripts, except for the animation handling ones, to make sure that its not something in the scripts thats causing it to stop.

Any help?

0
Try making it as a while loop, see if that helps Alucifer 45 — 8y
0
See my answer below for help :) Alucifer 45 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

What I did is make it a function and loop it. The NPC is now successfully moving to a random position every ten (10) seconds! (put the script in the NPC)

function move()

script.Parent.Humanoid:MoveTo(Vector3.new(math.random(-100, 100), 0, math.random(-100, 150)))
print("Done moving")

end

while wait(10) do

move()

end

There you go, you can change it up a little bit. Hope this helps!

Ad

Answer this question