Dialog choice will not run the function

Hello, I tried making a clear data dialogue using the DialogChoiceSelected function with a localscript. Problem is, it will not fire the event.

Code;

script.Parent.DialogChoiceSelected:Connect(function(plr, choice)
	if choice == script.Parent:WaitForChild("DataEdit"):WaitForChild("ClearDataOption"):WaitForChild("ConfirmYes") then
		print("yes")
	end
end)

Explorer:
Screenshot_313

(nothing prints in the console.)

You should use this in StarterPlayerScripts also locate the dialog in a variable

local Dialog = (YourDialogLocation)

Dialog.DialogChoiceSelected:Connect(function(plr, choice)
	if choice == Dialog:WaitForChild("DataEdit"):WaitForChild("ClearDataOption"):WaitForChild("ConfirmYes") then
		print("yes")
	end
end)

Tried that just now, it still errors, and does not print anything into the console.

This worked for me, be sure this is in a local also see if you have written the location of the dialog correctly

local Dialog = game.Workspace.YourNpc.Head.Dialog

Dialog.DialogChoiceSelected:Connect(function(plr, choice)
	if choice == Dialog.DataEdit.ClearDataOption.ConfirmYes then
		print("yes")
	end
end)

It is in the correct location. This is my new code now;

local dialoge = game.Workspace:WaitForChild("Helper"):WaitForChild("Base"):WaitForChild("Dialog")

dialoge.DialogChoiceSelected:Connect(function(plr, choice)
	if choice == dialoge:WaitForChild("DataEdit"):WaitForChild("ClearDataOption"):WaitForChild("ConfirmYes") then
		print("yes")
	end
end)

(still errors)

Don’t wait for child

Charrrrrs

I tested it with no WaitForChild and is firing the function correctly with the print

Did some external debugging and moving the parents, it now works.

1 Like