DialogChoiceSelected not working

(sorry if my english is bad)

Basically, I want to call a function when the player selects a DialogChoice on a Dialog.

I created a Script as a child of the Dialog and I wrote this:

local dialog = script.Parent

dialog.DialogChoiceSelected:Connect(function()
	print(".")
end)

The Dialog has two DialogChoices as children. It should print “.”, but it doesn’t. What am I doing wrong?

1 Like

I’d say in the function’s parenthesis, you can add a variable that will detect which one of the dialogs was chosen. ie. function(choice)
After that i’d write an ‘if’ statement which will print the “.” if such dialog was chosen.

local Dialog = script.Parent

Dialog.DialogChoiceSelected:Connect(function(Choice)
   if Choice == --Name of dialog choice in string format-- then
      print(".")
   end
end)

It still doesn’t work. I guess the problem is that it’s not firing the event DialogChoiceSelected

why would this do anything different? giving a non-functional connection a smaller scope would do absolutely nothing

the most likely issue here is that you are using a server script and not a local script; dialogue events only happen on the client and thus will only fire the event on a local script

where should the local script be? I created it as a child of Dialog, but it didn’t work (and it’s probably very wrong)

roblox localscripts will not run in the workspace, if you want to keep it in the same place change the runcontext of a regular script to “Local” instead of “Legacy”

2 Likes

Tysmmm :))) it worked. God bless you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.