Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help with DialogChoice actions?

Hi I need help on making a code that plays a sound when a dialog choice is selected. Can anyone let me know whats wrong with this?

script.Parent.DialogChoiceSelected:connect(function(plr, choice)


if choice.Name == “Play music” then

local song = script.Sound

song:Play()

end


end)

The script is inside the dialog.

Thanks

1 comment

0

Hold on, typing out the code.

1 answer

✓ Accepted answer

Introduction

I see your code.

The Answer

I haven't tested this, but it should work:

local sound = game.ServerStorage."your model"
local dialog = script.Parent

if dialog.Selected then
	local soundclone = sound:Clone()
	soundclone.Parent = "whatever your dialog is in".Head
	sound:Play()
	if sound.Ended then
		soundclone:Destroy()
	end
end

Conclusion

Like I said, this should work. Tell me if it doesn't.

1 comment

0

Thanks :)

This discussion is preserved as it was. New answers, comments, and votes are closed.