Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I connect a script to my dialog?

Asked by 5 years ago

I have this game that's almost finished! There's someone that you chat with (using dialog), and I want to make it so a specific dialog response turns on music. How would I go by doing this? I can't even seem to connect the script to the dialog in the first place! (The choice that is supposed to trigger the music is called DialogChoice1).

1 answer

Log in to vote
1
Answered by 5 years ago

So, in order to do this, you need to access the Dialog.DialogChoiceSelected event.

Here's an example of how to do it.

local dialog = --[path to dialog]
local dialogChoice1 = --[path to dialogchoice1]
local music = --[path to music sound]

dialog.DialogChoiceSelected:Connect(function(player, dialogChosen)
    if dialogChosen == dialogChoice1 then
        music:Play()
    end
end)

Hope this helped!

P.S. Here's where I got the information. This is a very useful Wiki page. https://developer.roblox.com/en-us/api-reference/event/Dialog/DialogChoiceSelected

Ad

Answer this question