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

Is there a way to preload audio to prevent this issue I'm having?

Sorry there isn't a lot of detail, as its a smaller question. My problem is that the audio in my game doesn't seem to work on the first attempt. For example when I have the audio set to play when I press or walk over a button, the audio doesn't work for the first time but then starts working for times following.

Thanks for the help!

1 comment

0

Hey, I just answered a similar question here. https://scriptinghelpers.org/questions/51737/how-am-i-supposed-to-preload-sounds-in-a-script. I think it might help you.

1 answer

✓ Accepted answer

Check out http://wiki.roblox.com/index.php?title=API:Class/ContentProvider -- the PreloadAsync should let you Preload the audio. Have that occur when the player loads into the place (in a LocalScript) and hope that you don't need the audio before it loads. If you have lots of preloading, you may want to prioritize what needs to be loaded first (ex maybe call PreloadAsync with the 10 most important resources, then when it gets back ask for the next 10, etc).

4 comments

0

Thank you so so much! I'll try this soon

0

Just a quick question, because I really don't know anything about preloading content - on the example they gave on the wiki, whats the purpose of blobking the thread until each has finished loading?

0

The purpose of waiting is so that the script will wait until everything is loaded in. That way the preload will actually preload. Note that for PreloadAsync to work on audio, you have to preload a SOUND instance with the ID set to the correct audio. (Unlike images which just require the ID.) Removing the Sound Instance will remove the preload.

0

It didn't work, so I'm going to look more into the script that plays the sound itself. Thank you so much for the help though!

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