Preloading Assets not always reliable?

I’m creating a broadway show in which NPCs chat to sing along to songs. I have used Audacity to time the lines perfectly, however the song doesn’t always play right away , even when I preload the assets at the beginning of the game.
Here is my preload script:

local Assets = {865189527} for _, asset in ipairs(Assets) do game:GetService("ContentProvider"):Preload("" .. asset) end

Playsong function:
function playSong(id) local"Sound" ,workspace) Music.Name = "Music" Music.SoundId = "" Music:Play() end
When I use it:

This is just a theory, but maybe it didn’t have enough time to fully preload?

It’s loaded at the beginning of the game, and the show starts when I click the button. I’m not sure that’s the problem?

Ok, this is kinda hard to explain, but, when you call Sound:Play() it will not start playing right away. Imagine roblox as 2 applications, one that plays the sound, the other does everything else. when you call Sound:Play(), the main application will send the request to start playing the sound to the other application, but that may take several microseconds because the sound “runs” faster than the actual roblox application.

Is there an alternative that works better?

It may be due to the fact that Preload() has been deprecated in favour of PreloadAsync(). You can learn more about it here at the announcement page and on the wiki.

When using PreloadAsync(), you have to create an array of instances rather than IDs.


you can try to build a buffer. Put in the audio some of the other audio. see when that “some other of the other audio starts playing in audacity or something” script it so the other sound starts playing once you are in that buffer. Once the other audio starts playing, put the timeposition as the other’s sound position and subtract by the buffer, now, the sound will seamlessly play like it was one.

Edit: found a video that explains more about the concept i talked about, it’s for a different game engine but still uses the same idea: