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