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

Help With Moving A NPC?

Bot.Humanoid:MoveTo(Pos)

This is part of my script for programming an NPC. Is it possible to make it so that it waits until Bot makes it to Pos before continuing on with the script, or am I going to have to figure out a way of doing this myself. I've already tried to fix this by putting it in a function rather than its own line of code by itself, but that didn't help.

1 comment

0

repeat wait() until Bot.Torso.Position == Pos?

1 answer

✓ Accepted answer

I would calculate how long it should take to walk there, wait that long, and if they still aren't there, recalculate and wait the new time until they arrive.

Bot.Humanoid:MoveTo(Pos)
while(Bot.Torso.Position-Pos).magnitude<5 do
	wait((Bot.Torso.Position-Pos).magnitude/Bot.Humanoid.WalkSpeed)
end

Give a range for how close it should be before it "arrives," because it isn't going to be exactly in that position.

1 comment

0

Oh my goodness thank you so much for this. I never would've figured it out myself!

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