0

# How do i detect when a player talks to a npc with a dialogue?

I am wondering how i can detect if a player talked with a npc using the dialogue, for context i am creating a shop that uses dialogue to buy the items.

1

If you are using Dialogue, you can use the event DialogChoiceSelected. This event detects whenever one of the dialogue choices has been selected in a dialogue.

For example, I have placed a TestDummy and have placed a Dialogue Onto It's Head, Then Inside the Dialogue, I have placed 3 Dialogue Choices.

I then created a local script and placed it onto StarterCharacter(this event only works locally).

local Dialogue = workspace.Dummy.Head.Dialog

Dialogue.DialogChoiceSelected:Connect(function(player, dialogueInstance)
print(player, dialogueInstance) --It has default params that gives you whoever triggered it and the dialogue choice,
--Do whatever you want here.
end)


Whenever one of the dialogue choices have been selected by the player, this event will trigger.

Note: Dialogue and DialogueChoices are two different things, DialogueChoices should be placed inside Dialogue.