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

Dialog Choice help?

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

✓ Accepted answer

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.

2 comments

0

Thanks for the help. ^^

0

No problem.

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