So i have an Npc chat system whenever you click on it’s dialog button it starts chatting as normal but i want to make a script that detects when a player clicks a respond button, when the player clicks the respond button i need like a gui to pop up.
So i have no idea about how could i detect if a player clicked the respond button.
i have tried the “DialogChoiceSelected” function but i can’t find my way around it.
Alright, so I have figured out your problem.
In the object browser, it tells me you have to give two parameters, not one. DialogChoiceSelected is an event only in a Dialog, not a DialogChoice. Therefore, when you use it, in the function, you have to set the instance player, and the instance DialogChoice. It is also client-side and will not work in a serverscript. And since LocalScripts don’t work in workspace, you have to put it somewhere else. I tested it, and it worked well in ReplicatedFirst, but it most likely works in StarterPlayerScripts as well. For more info, go here:Dialog | Documentation - Roblox Creator Hub
And since you want an event to fire on the client, I would suggest using a BindableEvent.
Here is the working code(in ReplicatedFirst or StarterPlayerScripts):
local Dialog = workspace.NPC.Head.Dialog
function selected(plr, choice)
if choice == Dialog.DialogChoice then
--code to fire a BindableEvent or whatever you want to happen.
end
end
Dialog.DialogChoiceSelected:Connect(selected)
Please mark this as the solution if it helps so if anyone else has the same problem, they can quickly get their solution.