Loading screen with PreloadAsync and RequestQueueSize but percentage instead of a bar

So basically I want to make a loading screen like dawn of aurora but with a percentage of how much has loaded and it closes when the percentage is at 100%.

Any ways to achieve this? Not trying to sound request-y but any help on it would be appreciated since I have made the GUI already:

2 Likes

You can have all of the IDs of the guis and important meshes in a table and preload them one at a time using PreloadAsync and update the percentage of assets loaded in the gui. The table should look like this:

local guiAssets = {
    Asset1 ID,
    Asset2 ID,
    Asset3 ID,
    -- etc.
}

local meshAssets = {
    workspace.Mesh1,
    workspace.Mesh2,
    workspace.Mesh3,
    -- etc.
}

Then for the guis, you’d create a temporary Image label and give its image property the current ID to be loaded from the gui table and call PreloadAsync on it. After that, you’ll destroy it to prevent memory leaks. For the meshes, you just call PreloadAsync directly on the meshes:

local cp = game:GetService("ContentProvider")
local totalAssets = #guiAssets + #meshAssets
local loaded = 0

for _, assetid in pairs(guiAssets) do
    local img = Instance.new("ImageLabel")
    img.Image = assetid
    cp:PreloadAsync({img})
    img:Destroy()
    loaded = loaded + 1
    loadedAssetsPercentage.Text = tostring(loaded / totalAssets) * 100) .. "%"
end

for _, mesh in pairs(meshAssets) do
    cp:PreloadAsync({mesh})
    loaded = loaded + 1
    loadedAssetsPercentage.Text = tostring(loaded / totalAssets) * 100) .. "%"
end

I wouldn’t use RequestQueueSize, due to it being unpredictable

9 Likes

Thanks, I will try this now. :slight_smile:

Can I use

workspace:GetChildren()

On the “meshes” thing?

You’d rather use the meshes table for important assets that you want to be uploaded. Plus, you don’t just want to pass the entire children of the workspace, especially if most are not meshes. It’s slow it down by iterating over all of the children when it can only load anything that uses content from the website

Not only can you use meshes there, you can use anything else there that uses content from the site that needs to be loaded other than images: Decals, Sounds. Just change the variable name to assets instead so that it doesn’t seem to be specific to meshes

You’d be better off by filtering the children to get the sounds, meshes and decals inside the workspace, but you may want to use GetDescendants instead, if some aren’t direct children of the workspace, but descendants

1 Like

Wait why is it saying that?

[16:22:47.391 - Unable to cast Array to Content]

16:22:47.391 - Stack Begin

[16:22:47.392 - Script ‘Players.MrOofBoyPlayz.PlayerGui.ScreenGui.TextLabel.Load’, Line 12]

16:22:47.392 - Stack End

Fixed it nevermind! Just had to take out the {} bit

Thank you so much sir :slight_smile:

Wait a second, is there any way to disable the “.” and the number after the dot. (Example: 34.2% should become just 34%)

Use math.floor, a function that rounds a number down:

loadedAssetsPercentage.Text = tostring(math.floor(loaded / totalAssets) * 100)) .. "%"

Ok also when it gets to 100% it says 100 instead of 100%

math.floor didnt work then, it got stuck on 0%

Edited:

math.floor((loaded / totalAssets) * 100) .. "%"

this worked fine

1 Like

Yep, it works now but what about the 100% thing? It still says “100” at the end instead of “100%”

Here is a screenshot of it saying “100” at the end instead of “100%”

Nevermind, fixed it. I had to take out the “wait(2)” thing lol.

Wait actually, I want to keep the wait(2) in but it removes the “%” of 100 at the end :frowning:

Any fix to this?

What is the wait(2) for? Show the updated code

Wait it only shows “100%” in the game but in studio it only shows “100” at the end

Thank you for all your help :slight_smile:

Hey dude, when I change like the window resolution (resizing the window I mean) it removes the % icon. Any scaling fix to this?