How to change an npcs walk sounds?

Is it possible to give an npc walking sounds when they move?

Currently, I have made an ai pathfinding npc, Is it possible to make the npc makes sounds when they do an action like walk?

I haven’t found any posts on it and i’m curious on how to make it.

5 Likes

This isn’t the most efficient way, but you can use :GetPropertyChangedSignal() on the NPC’s position. Something like this:

local npc = --the NPC's model.

npc.HumanoidRootPart:GetPropertyChangedSignal("Position"):Connect(function()
    print("moved")
end)

Supposed to, however it will play 1 sound per material, make sure your game has other floor materials besides smoothplastic and textures, like grass, glass, etc, add custom sounds for walking on each material and add that to the NPC so if the whole game is smooth plastic you will only hear the smooth plastic walking sound whenever the NPC moves

1 Like

If you want to get the floor material, you can use the humanoid’s FloorMaterial property. Like this:

local npc = --the NPC's model.

npc.HumanoidRootPart:GetPropertyChangedSignal("Position"):Connect(function()
    print(npc.Humanoid.FloorMaterial)
end)

For the sounds, you unfortunately have to make your own sounds that get played in that specific material.

(Keep in mind the FloorMaterial is set to nil when you’re not standing on anything.)

1 Like


This didnt seem to work! Nothing was printed

Because the NPC isn’t moving. My script detects whenever that does happen. If you want the NPC to move, that’s another matter.

Is that what you want?

Edit: Is the NPC moving? I can’t tell which one we’re focusing on.

Yes the npc is moving, It still isn’t printing anything

Did you set the “npc” variable to that Rig?
Show me the explorer and I’ll fill it out for you.

Yes I did, It still isn’t moving.
image

Try this now.

local npc = workspace.Rig

npc.HumanoidRootPart:GetPropertyChangedSignal("Position"):Connect(function()
    print(npc.Humanoid.FloorMaterial)
end)

It’s now referring to that Rig.

Still isn’t working…

Try printing that out every now and then. It’s either the function or the value that’s having the issue.

Try this:

while task.wait(0.1) do
    print(workspace.Rig.Humanoid.FloorMaterial)
end

Yes that works!

Edit: Now we need to do sound

We need to use a different function then, it can’t be looped.

Since you’re using a sound for the footsteps, we can use Sound.Stopped.

Do you already have a sound built in the rig?

If you don’t, just make a sound in the HumanoidRootPart.

Yes I do, I have a walking sound
image

You need to parent it in a physical part.
As previously mentioned, you can put it in the HumanoidRootPart.

1 Like

Oh yeah I forgot my bad! Its now in the humanoidrootpart

Keep in mind there’s a rule not to give out full scripts, so I’ll do my best to help you nevertheless.

1 Like

Alright! I just have no clue on how to do it