Help making a walking and talking npc

Does anyone know how I would be able to make a custom npc that walks and talks and has its own idle/walking animation?

3 Likes

Well, I am not super experienced with scripting or animating, but here’s some ideas.

  1. Do you want to use a ROBLOX animation? Or do you want to make your own?
  2. Would you like to make your own custom dialog GUI and script it, or would you like to use ROBLOX Studio’s generic dialog?

EDIT: FYI this is also Scripting Support, so it really is something you started scripting, but then got stuck on something.

1 Like

I want to make my own animation, but I want to use Roblox Studio’s dialog.

1 Like

This is easy.

Dialogue using the native dialogue options is a very simple concept.
Custom Animations are easy enough as well.

The thing here that might get complicated is the walky walky bit.

You see - I have no idea whether you want it to move around randomly or just move along a grid or what. But the general function for moving an NPC is Humanoid:MoveTo()

Unless you aren’t using a Humanoid. In that case, you could use physics bodies, or even just implement the physics yourself.

For the Animations, what I do is:

While in play test, copy the Animate LocalScript from my Character and then leave play test. I then paste the LocalScript into the NPC.
What you gotta do next is turn the Animate LocalScript into a Script while still keeping the contents and children - there is a line with “LocalPlayer” on, deleting that seemingly makes it work.

You can now change the idle Animation etc inside the LocalScript.


The dialog speech can be achieved by using Chat service’s :Chat function, for example:

local NPCHead = workspace.NPC.Head
local Chat = game:GetService("Chat")
Chat:Chat(NPCHead, "Hello, World!")

More is documented about the function here:

2 Likes

What I mean by what I said is for the NPC to walk to random locations and say things at random times aswell.

In that case you might want to just run a loop that goes off randomly and call ChatService.

As for random locations - you should definitely check out the link in my post that talked about movement.

You can grab the roblox Zombie and strip it of all the killing stuff and just leave it on idle without targeting.

It takes a while to learn the states though. But the zombie idles and walks around randomly waiting for a target. You just have your dialogue play at random times too and Bob’s your uncle.

Otherwise you can just make a much simpler version and do it from scratch. That’s a bit tricky.

I’d have a while loop running every half a second or so, not too much, and then have a os.time() thing and a random time in the future and if the 2 match up, trigger the move and update the new time in the future to do the next move. You can do the same for the dialogue.

But you will want to use pathfinding which is pretty full on. Directly moving will mean they get stuck on things and just moon walk until something pushes them out of the way. Path finding will walk around it.

As for pathfinding, I’m not too confident about that. Still don’t fully understand it. I just used the zombie pathfinding service.