Need help making an NPC talk

  1. What do you want to achieve? What is the issue?

My script spawns an NPC from a folder with various characters into a Workspace folder. Then, it should make the NPC state “hello”, but the NPC doesn’t actually state anything.

This is the script that I made for this:

local replicated = game:GetService("ReplicatedStorage") 
local ChatService = game:GetService("Chat")

local NPCdictionary = game.Workspace.NPC -- where NPCS are cloned to 
local NPCcharacters = replicated:WaitForChild("NPCchars") -- folder where characters are stored

local function spawnNPC()
	local selection = NPCcharacters:GetChildren()
	local randomNPC = selection[math.random(1, #selection)]
	local npc = randomNPC:Clone()
	npc.Parent = NPCdictionary
	npc.HumanoidRootPart.Anchored = false
	local root = npc:WaitForChild("HumanoidRootPart") 
	root.CFrame = NPCdictionary.Parent.NPCSpawn.TeleportPart.CFrame
	return npc, root -- root is just the HumanoidPart for the next code
end

local Dummy, Root = spawnNPC()
ChatService:Chat(Dummy.Head, "hello")

This script is in ServerScriptService, and the NPC does get spawned correctly like how I want it to but I’m having trouble with making the last line actually work.

3 Likes

Perhaps you have TextChatService.ChatVersion to TextChatService and not LegacyChatService. The old Chat service is superseded by TextChatService so you should try using that system instead.

Try TextChatService’s DisplayBubble function.

4 Likes

Perfect, this worked. Thank you so much!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.