Sound does not load

  1. What do you want to achieve?
    I want the sounds to play

  2. What is the issue? Include screenshots / videos if possible!
    The 2nd dialog sound doesn’t load

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to make sure syntax was correct,
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local dfolder = script.Parent

function createmessage(caption, sound)
	local message = Instance.new("Message")
	sound = dfolder:FindFirstChild(sound)
	if not sound then
		error("invalid sound")
	else
		message.Parent = game.Workspace
		message.Text = caption
		sound.Loaded:wait()
		sound:Play()
		task.wait(sound.TimeLength)
		message:Destroy()
	end
end

createmessage("Hello player, you have fell into a deep state of unconsciousness", "Dialog1")
task.wait(2)
createmessage("From what i have heard from the surface, you clicked on a teleporter which landed you here.", "Dialog2")

2 Likes

Did you check the dialog2 sound has the correct id and if you play it manually then it works fine?

2 Likes

yes i did try it and it the audio plays manually

1 Like

For some reason dialog2 is not loaded while dialog1 is loaded
Screenshot 2025-01-04 152205

Screenshot 2025-01-04 152214

you could try cloning the sound to a part and then play it, It’ll tell you if the issue is in the sound itself or with your script

I think this might be an issue with the audio rather than the script. You could check whether the audio was content-deleted or uploaded under a group. If the audio doesn’t load, try reuploading it. You can also click on ‘IsLoaded,’ which will display the error in the output.

1 Like

Hi guys! Problem was in sound.Loaded:wait()
Also i did some performance improvements

local dfolder = script.Parent

function createmessage(caption, sound:Sound)
	local message = Instance.new("Message")
	sound = dfolder[sound]
	if not sound then
		error("invalid sound")
	else
		message.Parent = workspace
		message.Text = caption
		sound:Play()
		sound.Ended:Wait()
		message:Destroy()
	end
end

createmessage("Hello player, you have fell into a deep state of unconsciousness", "Dialog1")
task.wait(2)
createmessage("From what i have heard from the surface, you clicked on a teleporter which landed you here.", "Dialog2")
1 Like

Why are you just trolling?
123123123

Load the sound into the workspace at the beginning of the game.
Just play it with your script.

Since loading it your way takes a while the script may timeout before the sound can play.