Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What function to use to detect a dialog choice?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!

0
Thank you potatoboy9999 :D! This was super helpful! Would this be a local script? BunnyFilms1 297 — 7y
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' BunnyFilms1 297 — 7y
Ad

Answer this question