Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you create a loading bar that waits for all of workspace to load?

Asked by 3 years ago
Edited 3 years ago

I have a game I want to add a loading bar to. It is just the map in workspace with normal roblox game streaming. I can’t figure out how to make it work all the tutorials I see use PreloadAsync on a replicated storage model. I can’t find any way to get a percentage or number of assets loaded from standard roblox loading. I don’t want to do that since it makes development hard and and empty void makes it annoying to mess with.

1 answer

Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

https://web.roblox.com/library/3648837674

You can calculate the percent like this:

local ContentProvider = game:GetService("ContentProvider")
local ItemsToLoad = game:GetDescendants()
local TotalItems = #ItemsToLoad
local Percent

wait(5) --Wait for the game to load up the assets, there are better methods, this is for testing
for Number,Object in pairs(ItemsToLoad) do

    Percent = math.floor((Number / TotalItems) * 100 + 0.5)
    ContentProvider:PreloadAsync({Object})  
    print(tostring(Percent) .. "%")
    --Set the loading bar size, make a label with the percent, blah blah blah

end
Ad

Answer this question