local Sound = Instance.new("Sound")
Sound.SoundId = "392838370"
ContentProvider:PreloadAsync({Sound}, print)
Why should you need an Instance? Why cant you just preload a raw Asset Id? What motivated this design decision? Is this somehow to save memory, and delete the asset if the Instance is destroyed?
local function Preload(AssetList : table, Callback : any)
local AssetsLoaded = 1
local AssetsToLoad = #AssetList
game:GetService("ContentProvider"):PreloadAsync(AssetList,function()
AssetsLoaded += 1
Callback(AssetsLoaded,AssetsToLoad)
end)
end
This is a function that I use to preload an array of AssetId’s.
You don’t need instances.
The Callback argument is a function that’s like this:
function(Loaded,ToLoad)
print(("%d/%d assets loaded"):format(Loaded,ToLoad))
end