Hi, I have a question on loading screens, I’ve been hoping if someone can show me a brief presentation on how to make a functional loading screen, preferably like mm2 loading screen where it shows how many parts have been loaded in, any help is appreciated.
There’s literally a reference for this:
But for your instance, you can use ContentProvider’s PreloadAsync function which takes an Array of Instances to load on the client side, I believe it yields until everything has fully loaded as well so you can confirm when it finishes loading
yeah but references by Roblox are hard to understand, if possible a brief demonstration could help.
Again as I said, PreloadAsync
takes an Array (Or table) of Instances to load, and when it’s called the current script will yield until everything has been fully loaded
We then get the current number (Or length) of assets we want to load by using the #
operator then putting our table through a loop to load everything:
local ContentProvider = game:GetService("ContentProvider")
local AssetsToLoad = {
workspace.Part;
game.ServerStorage.Maps;
game.ReplicatedStorage.Props;
true;
game.SoundService.Music;
}
local NumberOfAssets = #AssetsToLoad
local StartTime = os.clock()
for Index, Asset in pairs(AssetsToLoad) do
Gui.Frame.LoadingScreen.ProgressScreen.Size = UDim2.new(Index / NumberOfAssets, 0, 1, 0)
Gui.Frame.Loading.Text = "Loading... ("..Index.." / "..NumberOfAssets..")"
ContentProvider:PreloadAsync({Asset}, function()
end)
end
local DeltaTime = os.clock() - StartTime
print(("Preloading complete, took %.2f seconds"):format(DeltaTime))
And in this process, we’re also changing the size of our loading screen so that it shows the progress on how much things have loaded
After everything has been loaded, we then can compare how much time it took by using some string patterns to get the final time