DialogChoiceSelected not firing when I select a dialog choice

I have a Dialog object and I placed a script inside of it. The snippet that won’t fire is below:

script.Parent.DialogChoiceSelected:Connect(function (plr, dialog)
	if workspace.Status.npcActionDone.Value == true then
		workspace.Status.npcActionDone.Value = false
		wait(3)
		local module = require(game.ReplicatedStorage.NPCModule)
		local npc = module.spawnRandomFriend(plr)
		module.AddDialogueToPerson(npc)
		
		script.Parent.Parent.Parent:Destroy()
	end
end)

This won’t even print an error, it just think it doesn’t fire because of this.

Expected behavior

It should delete the NPC and spawn a new one with NPCModule:

script.Parent.DialogChoiceSelected:Connect(function (plr, dialog)
	if workspace.Status.npcActionDone.Value == true then
		workspace.Status.npcActionDone.Value = false
		wait(3)
		local module = require(game.ReplicatedStorage.NPCModule)
		local npc = module.spawnRandomFriend(plr)
		module.AddDialogueToPerson(npc)
		
		script.Parent.Parent.Parent:Destroy()
	end
end)
1 Like

Hi,

Thank you for reaching out on this issue.

Before we proceed, I’m wondering if you put this code into a LocalScript / ModuleScript required by a LocalScript? (See the documentation for more).

Thank you!

Oh my gosh, thank you! I didn’t know you had to use a LocalScript. I thought it was just a server thing.

1 Like

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