Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make sure my sound assets load 100% of the time?

Asked by 5 years ago
Edited 5 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.


local ReplicatedStorage = game:GetService("ReplicatedStorage") local ContentProvider = game:GetService("ContentProvider") local SFX = ReplicatedStorage:WaitForChild("Everything"):WaitForChild("SFX") local Assets = SFX:GetChildren() -- Load all sound assets. 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.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")
local SFX = ReplicatedStorage:WaitForChild("Everything"):WaitForChild("SFX")

local Assets = SFX:GetChildren()

-- Load all  sound assets.

    for i, v in pairs(SFX:GetChildren()) do 
        SFX:WaitForChild(v.Name) -- Am I doing this wrong?
    end

    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?

0
You could use :WaitForChild() Vid_eo 126 — 5y
0
I'm using :WaitForChild() on both the folder that "SFX" is inside of and "SFX" itself, do you mean wait for all the children inside of SFX? I could try that. jackfrost178 242 — 5y
0
Hmm that didn't seem to work either. jackfrost178 242 — 5y

Answer this question