Hi there:
Since the removal of the :Preload() function from ContentProvider I have been struggling to efficiently load the assets into the game. This is, the game takes long (to the point the client disconnects from the server due to timeout) to load for it’s development stage!
How do I load the assets:
- I request the list from a module serverside:
-- the actual module has way more entries than this.
local images = {
{"icons/arrow_button_left", 1243045644},
{"icons/arrow_button_right", 1243045650},
{"icons/logo_a", 1254423406},
{"icons/logo_a_stroked", 1254423411},
{"icons/logo_d", 1254423354},
{"icons/logo_d_stroked", 1254423402},
}
local meshes = {
{"meshes/environment/lobbyGarage/door_extruded", 1145143218},
{"meshes/environment/lobbyGarage/door_lock", 1145143732},
{"meshes/environment/lobbyGarage/lights_main", 1145144022},
{"meshes/environment/lobbyGarage/lights_main_frame", 1145144300},
{"meshes/environment/lobbyGarage/lights_side", 1145165736},
{"meshes/environment/lobbyGarage/main", 1145166425},
}
return {images, meshes}
The first value of each table is just a “want” and not necessarily a “need”. Said value is displayed in the Loading Gui. Second value is the rbxassetid.
- When the list arrives at the script:
-- assetLibrary is the module above
for _,v in pairs(assetLibrary[1]) do
ImageLabel.Image = "rbxassetid://"..tostring(v[2])
asset.Text = "Loading File "..tostring(loadedAssets + 1).." of "..tostring(assetNum)..":"
assetName.Text = v[1]
progress.Text = tostring(math.floor((loadedAssets/assetNum) * 100)).."%"
contentLoader:PreloadAsync({ImageLabel})
loadedAssets = loadedAssets + 1
end
print(plr:GetMouse().Icon)
plr:GetMouse().Icon = "rbxgameasset://Images/cursor"
for _,a in pairs(assetLibrary[2]) do
MeshPart.MeshId = "rbxassetid://"..tostring(a[2]) -- i'm using a SpecialMesh since it's MeshId property can be written.
asset.Text = "Loading File "..tostring(loadedAssets + 1).." of "..tostring(assetNum)..":"
assetName.Text = a[1]
progress.Text = tostring(math.floor((loadedAssets/assetNum) * 100)).."%"
contentLoader:PreloadAsync({MeshPart})
loadedAssets = loadedAssets + 1
end
I load each asset individually because I want to keep track of how many assets are already loaded. If I call the :Preload() function with all the assets, it would yield the script until loading was done.
What is happening:
All images are “failing” to load:
--23:26:53.027 - ContentProvider:PreloadAsync() failed for rbxassetid://1243044904
--23:26:53.458 - Image "https://assetgame.roblox.com/asset/?id=1243044981" failed to load in "TextureManager::PreloadTexture": Request failed
I am not sure if this is a failure/ineficiency on Roblox’s end to send the data or an issue with the loading script.