Playing a sound when opening a dialog

  1. What do you want to achieve?
    I want to play a sound for the player when he opens a dialog (clicks on the question mark)

  2. What is the issue?
    I could not find a way to play the sound when the player clicks on the question mark. I found a way to play the sound, but only if the player chooses a DialogChoice.

  3. What solutions have you tried so far?
    I’ve looked up on the internet and devhub for solutions, but couldn’t find one.

Thanks if you can help me! :wink:

1 Like

I found this post regarding this topic that could help.

Thank you for finding it, it prints but wont play the sound

Can you send your code where it’s supposed to play the sound?

Sure! Here is the code:

local dialog = script.Parent
local sound = script.Parent.sound

dialog:GetPropertyChangedSignal("InUse"):Connect(function()
	if dialog.InUse == true then
		print("Playing")
		sound:Play()
		print("Played")
	end
end)

It prints both “Playing” and “Played” but the sound still wont play.

Just use

Local sound = -- where ever your sound is
	sound:play() -- put this wherever you want it to play at assuming you're using a script for this dialog

Or is the dialogue Roblox’s dialogue?

I dropped this in a menu for a test … works fine when opened.
LocalScript, in the frame… sound within.

local frame=script.Parent
local sound=script:WaitForChild("Sound")

frame:GetPropertyChangedSignal("Visible"):Connect(function()
	if frame.Visible then
		sound:Play()
	end
end)

Yes, it is Roblox’s dialogue. It is not a UI.