Sound following/blind NPC

How can I go about making an NPC that can hear but not see? I want the NPC to follow sounds and players (when they’re not crouching and making noise). How can I do this? I also want the NPC to stop following after the player gets far away and stops making noise (so when they’re crouching again and sounds aren’t playing). Thanks in advance!

You could try doing a distance check everytime a sound is played. Like between the sound and the NPC. Or shoot a raycast so it doesnt go through walls but there you might have to play around a little to get it working well

1 Like

You can try creating a module script and fire a function everytime a sound is played (like footstep). And pass in values like position, volume. After that you can make the npc move to that position

1 Like

Here is how I would approach this:

Anytime that you play a sound in your game, you will need to signal the position and volume of the sound effect to any other script that reacts to it (in this case probably the script inside the npc.) To do this, I would create a RemoteEvent called something like “SoundSignal” and put it into ReplicatedStorage. Then, create a simple function similar to the one below.

local function sendSound(position, volume)
	local event = game.ReplicatedStorage:FindFirstChild("SoundSignal")
	event:FireServer(position, volume)
end

Then, on any script that you want to “hear” the sounds, listen for the event.

local event = game.ReplicatedStorage:FindFirstChild("SoundSignal")
event.OnServerEvent:Connect(function(position, volume)
	--Write you code here
end)

Something like this should be pretty adaptable. You can of course use stuff like humanoid:MoveTo(position) to make an NPC react.

1 Like