How to make a walking NPC

Hello there developers!

Have you ever wanted an NPC that walks to a specified location? Well then your in luck, because I made a script that will make an NPC walk to specified locations.

Here are the following steps:

  1. Add a rig to your workspace.

  2. Add a script inside of the rig.

  3. Paste the following inside the script:

local NPC = game.Workspace.Rig -- Feel free to name the model and the parts to whatever you want! You may change the waiting time if you wish!

while true do
	NPC.Humanoid:MoveTo(game.Workspace.Part.Position) 
	NPC.Humanoid.MoveToFinished:Wait()
	wait(5)
	NPC.Humanoid:MoveTo(game.Workspace.Part2.Position)
	NPC.Humanoid.MoveToFinished:Wait()
	wait(5)
	NPC.Humanoid:MoveTo(game.Workspace.Part3.Position)
	NPC.Humanoid.MoveToFinished:Wait()
	wait(5)
end

It is highly recommended that you set the transparency of the parts to 1 and turn off CanColide. I hope this script helped you guys a lot! Feel free to send feedback down below!

5 Likes

There is better ways of doing this but it is still nice to see people making things for the community :slight_smile:

3 Likes

not the best way to do this but good for beginner programmers

2 Likes