How to make my character die when it picks a certain dialogue option

I want to make it so that my character dies when it asks this creeper “What will happen if i do?.”

here is the current script

script.Parent.Activated:Connect(function()
	game.Players.LocalPlayer.Character.Humanoid.Health = 0
end)

currently Ive tried to consult chat gpt and ive looked through the dev forum and a similar topic but i cant get it to work.

1 Like

in the local script you can detect when the player selects the dialogue choice like this:

local dialogobject = --path to the dialog object
local killchoice = --path to the dialog choice which kills player

dialogobject.DialogChoiceSelected:Connect(function(choice)
    if choice == killchoice then
        game.Players.LocalPlayer.Character.Humanoid.Health = 0
    end
end)
1 Like

Get the Dialog instance and connect it to a DialogChoiceSelected event. Then check if the DialogueChoice from the function equals the death one.

1 Like

seems to be on to something but it still isnt working here is what i tried

 local dialogobject = script.Parent
	local killchoice = dialogobject.DialogChoice.yes.DialogChoice.Death

	dialogobject.DialogChoiceSelected:Connect(function(choice)
		if choice == killchoice then
		game.Players.LocalPlayer.Character.Humanoid.Health = 0
	end
end)

and heres the paths

image