NPC Chat Script Error

Hi! I’m PinkScripts, a programmer. I was creating a script earlier and I encountered an error while trying to get my NPCs to chat. It is extremely weird because It worked for the first 3 NPCs, but the following NPCs came up with an error. I duplicated the NPCs and all I changed was the string, which changes the text of what the NPC says.

My script:

local chat = game:GetService("Chat")
local head = script.Parent.Head
	 
while true do
	chat:Chat(head, "Hello, I am Aesterza!", "White")
	wait(5)
	chat:Chat(head, "I am the Vice-President of Embassy Resorts!", "White")
	wait(5)
	chat:Chat(head, "Do check out our Cafe! We have delicious donuts!", "White") 
	wait(5)
	chat:Chat(head, "Do leave a like on the game!", "White") 
	wait(5)
end 

My error:

All my NPCs, including the ones in which the Chat Scripts have no errors, are placed under a folder under the workspace. Please let me know if you know is a solution to this! Thank you!

did you put the script and npc in workspace?

Are you cloning the npc? If that’s the case then add an event that gets triggered to trigger the code.

Could you please send us the Explorer window where the ‘head’ is located?

1 Like

I don’t know if it’ll change anything but try to take the NPC out of the folder. Maybe that’s the problem, idk.

I put the script under the NPC in a folder in Workspace.

Right under the NPC model, which is located under the workspace.

Your script may not work because you are referring to ‘head’ which isn’t under Workspace, but the character you can refer to too. Try to replace ‘head’ with the NPC model:

local head = script.Parent.Head >>> local npc = script.Parent

Let me know if it helps!

1 Like

This still doesn’t let it work…

It still doesn’t work, not sure why.

I don’t know then, sorry. All you can do is restarting Roblox studio, if this doesn’t help then restarting your PC and if even this doesn’t help then just reinstall Roblox Studio. If any of this doesn’t work and it isn’t showing any errors, then contact Roblox support through here Support - Roblox (It may take a while until they get to solving your report).

1 Like

Np, it’s really weird because it works for some NPCs but not others.

It may also be other issue but I don’t know what could possibly stop you from firing Chat:Chat().

1 Like