How do I make an NPC teleport to a player when they say something in chat?

Hello!

I ran into a problem and do not know how to progress.
So basically, if you say a specific word in chat, a monster appears behind you and takes you.
I’ve already gotten the “takes you” part down, I just need to find a way to incorporate the chat and “monster appears behind you” part.
Except, I do not know how to do any of this. I am stuck. I’ve looked at similar forums, but none of them would be of use to me. Here is a video so you can see what the “takes you” part looks like.


any help would be appreciated. Thanks!

For this you’ll need the Chatted RBXScriptSignal object (event) of player instances, its parameter represents the message that was chatted.

https://developer.roblox.com/en-us/api-reference/event/Player/Chatted

local players = game:GetService("Players")

local npc = workspace.Dummy --Example dummy model.

players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		local character = player.Character or player.CharacterAdded:Wait()
		
		if message:lower():match("^:tp%snpc$") then
			npc:PivotTo(character:GetPivot())
		end
	end)
end)

The command is :tp npc, it can be changed if necessary.

2 Likes