I’m currently having a game called Even more FNF, The game is a rythm type of game which really depend on the musics. But I have one big problem:
Loading time is long / Some assets refuse to load if fail once.
Since I’ve open the game to mobile and tablet. I’m regularly having people complaining about not loading properly. I’ve been trying to find an efficient way to load without annoying the users by preloading the needed songs before a play is perform. My current method is the following:
BASSETS = {}
local Max, Cur = 0, 0
for _,v in pairs(Songs) do
if v:IsA("Sound") then
Max = Max + 1
if not v.IsLoaded then
table.insert(BASSETS, v.SoundId)
-- Trying to load the sound by playing it silently
local l = v:Clone()
l.Parent = game.Players.LocalPlayer.PlayerGui.MainGui
l.Volume = 0
l:Play()
game.Debris:AddItem(l, 1)
else
Cur = Cur + 1
end
end
end
if #BASSETS == 0 then
break
end
game.Players.LocalPlayer.PlayerGui.MainGui.LoadingSong.TxtData.Text = "Downloading data... (" .. Cur .. " / " .. Max .. ")"
game:GetService("ContentProvider"):PreloadAsync(BASSETS)
If you can download the sound for the first time. The game doesn’t preload the songs anymore. But if it fail, It will never be able to load the sounds for some reason (The upper code is in a loop)
What it look like for someone that can’t load a particular music