How do I make sure my sound assets load 100% of the time?
Asked by
6 years ago Edited 6 years ago
I've been trying to load my sounds using PreloadAsync, but sometimes when I join my place, the sounds just fail to load and they never play(even if I stay for half an hour). I have to keep rejoining the place until all the sounds load correctly.
I do have a very slow computer and I thought that might be the issue, but i've played some very polished games like Hexaria, and even though the sounds in Hexaria can sometimes take a couple minutes to load for me, they still load every single time without me having to rejoin.
Heres what i've been using to try and load in my sounds.
1 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
2 | local ContentProvider = game:GetService( "ContentProvider" ) |
3 | local SFX = ReplicatedStorage:WaitForChild( "Everything" ):WaitForChild( "SFX" ) |
5 | local Assets = SFX:GetChildren() |
8 | ContentProvider:PreloadAsync(Assets) |
I put all the sounds assets in one folder called "SFX"(which is inside of a folder called "Everything"), and i'm inserting them into the Assets table. Then I try to load all the assets in the table using the ContentProvider service, but that just doesn't seem to work 100% of the time.
I've also just tried to wait for all the children inside of the "SFX" folder using the code below.
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local ContentProvider = game:GetService( "ContentProvider" ) |
03 | local SFX = ReplicatedStorage:WaitForChild( "Everything" ):WaitForChild( "SFX" ) |
05 | local Assets = SFX:GetChildren() |
09 | for i, v in pairs (SFX:GetChildren()) do |
10 | SFX:WaitForChild(v.Name) |
13 | ContentProvider:PreloadAsync(Assets) |
This unfortunately didn't work for me either after some testing.
What is the best way to make sure all the sounds load?