Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What function to use to detect a dialog choice?

What function would detect something I answer back to a NPC. For example, if I said no to it, how would I detect that I said no to it and be able to run a script that caused the NPC to walk to a point. Below is my current script:

while true do

order = game.Workspace.FoodTruck1.Order.Position

script.Parent.WalkToPoint = order
wait ()

end

1 answer

✓ Accepted answer

In order to detect what they choose you would use the DialogChoiceSelected event. For example:

local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
 
    if choice == script.Parent.DialogChoice.ChoiceA then
    		--Does the thing you want
        end
    elseif choice == dialog.DialogChoice.ChoiceB then
        	--Does the other thing
        end
    end
end)

Good Luck!

2 comments

0

Thank you potatoboy9999 :D! This was super helpful! Would this be a local script?

0

Also, when I use the script, it says this: Workspace.NPC1.Head.Dialog.Script:7: 'end' expected (to close 'function' at line 2) near 'elseif'

This discussion is preserved as it was. New answers, comments, and votes are closed.