What do you want to achieve?
I want the sounds to play
What is the issue? Include screenshots / videos if possible!
The 2nd dialog sound doesn’t load
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")
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.
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")