NPC bubble chat not working

I’ve made a script that will detect any npcs in a folder in workspace. The script will also detects whether this npc’s attribute named “CanTalk” is true or not. If it’s true then the npc can talk, but if not then it cannot talk. The script seems to work perfectly fine, I put some print() and make the script able to recolor the head of the npc and it did everything very well with no errors. The problem is that the script can’t show the bubble chat above the npc’s head like it just completely ignores that particular line of code. I might miss something important here and I don’t even realize it. Here’s the code and I hope someone can figure out what causes this and how to fix it. Also the script is located at ServerScriptService.

local textchatservice	= game:GetService("TextChatService")

for _,v in pairs(workspace.NPCs:GetChildren()) do
	local head	= v:WaitForChild("Head")
	if v:GetAttribute("CanTalk") == true then
		print(v.Name.." Can talk true")
		textchatservice:DisplayBubble(head, "Hey test one two")
		head.Color	= Color3.new(0, 1, 0)
	else
		print(v.Name.." Can talk false")
		head.Color	= Color3.new(1,0,0)
	end
end
1 Like

Hi, I think I found your problem! You would need a local script to use the method “:DisplayBubble”. I made three scripts, two scripts in StarterCharacter and one in ServerScriptService. In the StarterCharacter, I used your code and just changed the type of script (one local script and one script). It seems that only when I used the local script, did the Text Bubble actually appear on the NPC. I hope this helps!

2 Likes

Ooh this looked like an easy fix and yes it is! I just noticed that chat happens in client side. I just have to move the script to StarterCharacter and make it a localscript. Thanks for the help!

1 Like

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