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

Dialog Choice help?

Asked by
Xl5Xl5 65
8 years ago

With this code this happens with any selected dialog choice.

How can I make specifically when player picks "choice1", he doesn't die but when the player picks "choice2" he dies? How would I go about doing this?

script.Parent.DialogChoiceSelected:connect(function(player,choice) local humanoid = player.Character:findFirstChild("Humanoid") if humanoid then wait(1) humanoid.Health = 0 end end)

Please help, many thanks!

1 answer

Log in to vote
0
Answered by 8 years ago

As well as having a player argument that shows who clicked the DialogChoice, the DialogChoiceSelected event also has a choice argument that is the DialogChoice instance that the player has selected.

With this knowledge, you can make one thing happen if the dialog choice's name is one name and you can make another thing happen if the dialog choice's name is another name.

script.Parent.DialogChoiceSelected:connect(function(player,choice)
    local humanoid = player.Character:findFirstChild("Humanoid")
    if not humanoid then return end --End the function if the humanoid isn't found
    if choice.Name == "Die" then --If the DialogChoice's name is Die then do the following
        wait(1)
        humanoid.Health = 0  --Set health to 0.
    elseif choice.Name == "Jump" then
        wait(1)
        humanoid.Jump = true --Make the player jump.
    end
end)

I hope my answer helped you. If it did, be sure to accept it.

0
Thanks for the help. ^^ Xl5Xl5 65 — 8y
0
No problem. Spongocardo 1991 — 8y
Ad

Answer this question