What do you want to achieve? I’m trying to make it so that there is an NPC with 3 final dialog options, and each one of them will do a different thing. The main thing I want is for a model inside the NPC’s model to disappear locally and also locally trigger a value if possible, so that you can place the item later.
What is the issue? Nothing happens when I select the right final dialog option.
What solutions have you tried so far? I have tried to get help from other sources, looked on the devforum for anything about this, and tried to do it myself, but I am unsuccessful.
This is my current code.
local mesh = game.Workspace:WaitForChild("Statue"):WaitForChild("Body"):WaitForChild("Head")
local model = mesh.Parent
local dialog = model.PlayerGui:WaitForChild("Dialog")
local value = game.StarterPlayer.StarterCharacterScripts:WaitForChild("GotBurger")
-- code to display the dialog
while true do
local options = dialog:GetOptions()
for i, option in ipairs(options) do
if option:GetText() == "" then
-- code to execute when the player finishes the entire set of dialog
if option:GetText() == "get out of my temple >:(" then
-- code to execute if the player selects the first final option
elseif option:GetText() == "ok here you go" then
script.Parent.Parent.Parent.BurgerItem:Destroy()
value.Value = true
elseif option:GetText() == "NO." then
-- code to execute if the player selects the third final option
end
break
end
end
wait()
end
I’m not sure about the PlayerGui part. I got that from someone else, and it’s probably wrong. The output window says nothing, which is one of the reasons I’m so confused about this.
the Dialog is located in the NPC’s head (Mesh), thus line 3 will not work. GetOptions() does not even exist, so line 9 is broken.
There’s a bunch more stuff wrong, but I rewrote it for you:
local mesh = game.Workspace:WaitForChild("Statue"):WaitForChild("Body"):WaitForChild("Head")
local model = mesh.Parent
local dialog = mesh:WaitForChild("Dialog")
local value = game.StarterPlayer.StarterCharacterScripts:WaitForChild("GotBurger")
-- code to display the dialog
dialog.DialogChoiceSelected:Connect(function(plr, Choice)
if Choice == "" then
if Choice == "get out of my temple >:(" then
-- code to execute if the player selects the first final option
elseif Choice == "ok here you go" then
script.Parent.Parent.Parent.BurgerItem:Destroy()
value.Value = true
elseif Choice == "NO." then
-- code to execute if the player selects the third final option
end
end
end)
Try it out, if it doesn’t work then I’ll be happy to keep helping you
Ah, that explains why it does not work. Place the script in StarterPlayerScripts or ScreenGui, and if it doesn’t work, change it into a Server Script and put it back in the head
That’s nice, but if the events for the dialog choice trigger in a server script, which will activate it for everyone, that defeats the purpose of the script, because the events are only meant to trigger for the people who have gotten the right dialog.