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

How would I make a dialogue option that plays a sound when selected?

Asked by 5 years ago

I'm trying to make a dialog choice that when selected plays a sound effect. Can somebody help me out?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

very easy and simple :) by using DialogChoiceSelected we can check to see if a certain choice was selected, and do something.

  • firstly, you need dialog. and a character. this is a very good API that has a lot of customization:

https://www.roblox.com/library/59391730/Advanced-Player-AI

  • in the player model go to "Head", insert Dialog. under Dialog insert DialogChoice. I inserted two, "Yes" and "No" make sure the names are spelled exactly as you put them in code (case sensitive)

  • insert an Audio in ReplicatedStorage and make a local variable pointed to that audio

  • the following script goes under StarterGui

local Dialog = game.Workspace.Player.Head.Dialog
local Voice = game.ReplicatedStorage["YES! YES!"]

Dialog.DialogChoiceSelected:Connect(function(player,choice)
    if choice.Name == "No" then
        player.Character.Humanoid.Health = 0
    elseif choice.Name == "Yes" then
        Voice:Play()
    end
end)

and boom. if you say no you die, if you say yes the audio played

hope I helped, accept the answer if I did :)

Ad

Answer this question