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

Npc path script not working? -(ANSWERED)

Im trying to get my Npc to move from part to part but all he does is stand there?

print("Doge Moveing") -- Just to see if the script is running
	Part = game.Workspace.G.Position
	Part2 = game.Workspace.G1.Position
	Part3 = game.Workspace.G2.Position
while true do
	game.Workspace.Doge.Humaniod:MoveTo(Part)
	wait(15)
	game.Workspace.Doge.Humaniod:MoveTo(Part2)
	wait(15)
	game.Workspace.Doge.Humaniod:MoveTo(Part3)
	wait(15)
end

1 comment

0

First off, you spelled Humanoid wrong. Second off, you can't use :MoveTo on a Humanoid, you use it on the Torso of the NPC.

2 answers

✓ Accepted answer

Ok, first of all, the first answer is incorrect. Yes, you did misspell Humanoid. And based on your question, you want the character to walk to the location, right?

The fixes:

print("Doge Moving") -- Just to see if the script is running
Part = game.Workspace.G.Position
Part2 = game.Workspace.G1.Position
Part3 = game.Workspace.G2.Position

while true do
	game.Workspace.Doge.Humanoid:MoveTo(Part)
	wait(15)
	game.Workspace.Doge.Humanoid:MoveTo(Part2)
	wait(15)
	game.Workspace.Doge.Humanoid:MoveTo(Part3)
	wait(15)
end

A Humanoid's MoveTo method takes one argument and one optional argument (Vector3 location, Instance part = nil). The MoveTo method in Humanoids make the humanoid WALK to the location given.

I looked in the wiki. NOWHERE did I see that Parts have a :MoveTo method. This is why the others are wrong.

1 comment

0

Thank you :D - Oh and i delete my post sense you edited

First off, there are a few things wrong with your script.

  1. You spelled "Humanoid" wrong.
  2. You don't use MoveTo() on a humanoid.

Fixes: You need to call MoveTo() on the torso, because humanoid doesn't use MoveTo() Removed humanoid because you don't use humanoid with MoveTo()

print("Doge Moving") --Fixed speling mistakes

part = game.Workspace.G.Position
part2 = game.Workspace.G1.Position
part3 = game.Workspace.G2.Position

while true do
	game.Workspace.Doge.Torso:MoveTo(part) --Fixed MoveTo() on lines 6, 8, and 10. (Don't forget to use torso, not humanoid!)
	wait(15)
	game.Workspace.Doge.Torso:MoveTo(part2)
	wait(15)
	game.Workspace.Doge.Torso:MoveTo(part3)
	wait(15) --Don't forget to always end a while true do loop with a wait.
end

2 comments

0

Lol, Thanks i dent know i spelled humanoid worng

0

Yes, Humanoid DOES have a :MoveTo() method. It just makes the character WALK to the position instead of teleporting. Also, Parts do NOT have a :MoveTo() method. Only models and humanoids.

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