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

How to influence NPCs with voice commands?

So I am a very basic scripter right now, but I want to work with NPCs for the sake of making a few fun games and maybe sell-able tech on Roblox. This question is in two parts:

  1. How do I make it so NPCs can operate on a path? I.e. walking forwards, backwards, forming ranks, etc.

  2. How do I make it so NPCs are influenced by in-chat voice commands?

Thanks!

1 answer

Make sure you post some more information about what you want next time you ask for help (Source code, errors, etc.)


To answer your first question, you'll need to use the MoveTo function. In this code I'm assuming you have a zombie/NPC ready, so put the following code in a script in ServerScriptService:

local zombie = PutTheZombieLocationHere
local location = PutThePartLocationHere

zombie.Humanoid:MoveTo(location.Position,location)

Make sure replace the zombie and location variables with the dummy and the part you want the dummy to move to


For your second question, put this code in a script in ServerScriptService:

local message = "WhatYouWantThePlayerToSay"

local zombie = PutTheZombieLocationHere
local location = PutThePartLocationHere

function moveZombie()
	zombie.Humanoid:MoveTo(location.Position,location)
end

game.Players.PlayerAdded:connect(function(plr)
	plr.Chatted:connect(function(msg)
		if msg == message then
			moveZombie()
		end
	end)
end)

Make sure replace the zombie, location, and message variables with the dummy, part you want the dummy to move to, and the message to make the zombie move.


If you have any problems with my script, be sure to let me know and we'll try to work it out together.

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