Load Image and Sounds when failed to load

How to wait until all Images and Sounds in Game has loaded and if some Sounds and Images failed to load, how to reload it every time when its failed again and wait until all is loaded?

For this I recommend a module for it, like my own, it does this.

Although for your issue it might not be right, so here’s some code,

local Folder = workspace.Folder:GetChildren()
local CP = game:GetService("ContentProvider")
for i, v in ipairs(Folder) do
		local succ, err = pcall(function()
		if not succ then
			warn("Something went wrong! "..err)

	until succ
1 Like
local contentProvider = game:GetService("ContentProvider")

local instance = script.Parent

if not instance:IsLoaded() then
	until instance:IsLoaded()

You can use this to check if the instance is loaded. If it does not load then it would use PreloadAsync to load the asset.

1 Like

But IsLoaded takes some times to load is there a way to find out if the Image or Sound is failed? And how could use this for the whole game so if the sound somewhere fails it also preload the Sound what failed or Image

Thanks but I readed sometimes that i shouldnt use pcall for PreloadAsync is that right?

Use the pcall, it selects if something has gone wrong.

Can i also use this for Sound in Server Script?

Where do you want the sound, when it errors or loads?

The Sound is in a Vehicle, the Vehicle is in Workspace

I was asking when you want it to play.

It should all load first when the Player joins and when the Player want to drive the Vehicle the Sound can play