I have a loading screen that says how much of the game has loaded in and it works fine in Studio, however when I tried it in the game it gets stuck on Terrain. I tried to ignore terrain but it still gets stuck around that count for some reason. Don’t know how to debug this either.
My code:
local assets = game:GetDescendants()
for i = 1, #assets do
local asset = assets[i]
ContentProvider:PreloadAsync({asset})
intro.LoadingFrame.Assets.Text = "Loading: "..asset.Name.." ["..i.."/"..#assets.."]"
end
I Think I Am Not Helping Here But I Suppose You Already Have It Like This?
local assets = game:GetDescendants()
local ContentProvider = game:GetService("ContentProvider")
for i = 1, #assets do
local asset = assets[i]
ContentProvider:PreloadAsync({asset})
script.Parent.Text = "Loading: "..asset.Name.." ["..i.."/"..#assets.."]"
end
Without This Line Of Code It Would Completely Not Work But I Don’t See It In The Code Above, I Suppose You Didn’t Copy It?
local ContentProvider = game:GetService("ContentProvider")
Each PreloadAsync() call counts as an individual network request. The roblox server has a limit on the number of network requests per minute per player on your game. Making too many requests in quick succession will cause the client that is making the requests to get throttled. Try getting rid of the for loop and throw the entire assets table into PreloadAsync (it supports this)
callback is to update the loading screen
local i = 1
local callback = function(name, status)
intro.LoadingFrame.Assets.Text = "Loading: " .. name .. " " .. i .. " / " .. #assets
i = i + 1
end
ContentProvider:PreloadAsync(assets, callback)
note: this groups all the assets into 1 single network request, but since you have 6603 assets to preload, the single request is massive and may still get throttled
put print(name, tostring(status)) inside the callback function to see which one is unsuccessfully loading and the reason why