Speed Up Loading Screen

I have a loading screen that uses this code but the loading screen takes a very very long time so I was woundering if there was any way to speed up the loading. I’m sorry if the code looks weird I do not know how to correctly upload the code to this post.

local MainScreenGui = script.Parent
MainScreenGui.Enabled = true
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local ContextActionService = game:GetService(“ContextActionService”)

local character = player.Character or player.CharacterAdded:Wait()
character:WaitForChild(“HumanoidRootPart”).Anchored = true

local waitFrame = script.Parent:WaitForChild(“WaitFrame”)
waitFrame.BackgroundTransparency = 0
local cameraPart = workspace:WaitForChild(“CameraPart”)

camera.CameraType = Enum.CameraType.Scriptable

camera.CFrame = cameraPart.CFrame

local ContentProvider = game:GetService(“ContentProvider”)
local MainFrame = MainScreenGui:WaitForChild(“MainLoadingScreen”)
local TweenService = game:GetService(“TweenService”)
local blur = game.Lighting:WaitForChild(“Blur”)
blur.Enabled = true
local statsGui = script.Parent.Parent:WaitForChild(“StatsGui”)
local upgradeGui = script.Parent.Parent:WaitForChild(“UpgradeGui”)
statsGui.Enabled = false
upgradeGui.Enabled = false

local FadeTween = TweenService:Create(MainScreenGui.WaitFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {BackgroundTransparency = 1})
FadeTween:Play()

repeat wait() until game:IsLoaded()

local GameAssets = game:GetDescendants()
local TotalGameAssets = #GameAssets

local LoadBar = MainFrame:WaitForChild(“BackgroundBar”):WaitForChild(“MovingBar”)

LoadBar.Size = UDim2.new(0, 0, 1, 0)

local function updateLoadingText(progress)
MainFrame:WaitForChild(“ProgressText”).Text = string.format(“Assets Loading: %d/%d”, progress, TotalGameAssets)
end

MainFrame:WaitForChild(“ProgressText”).Text = “Assets Loading: 1/” … TotalGameAssets
wait(0.5)

for i, assetToLoad in ipairs(GameAssets) do
ContentProvider:PreloadAsync({assetToLoad})
updateLoadingText(i)
LoadBar.Size = UDim2.new(i / TotalGameAssets, 0, 1, 0)
end

local FadeInTween = TweenService:Create(MainScreenGui.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {BackgroundTransparency = 0})
FadeInTween:Play()
FadeInTween.Completed:Wait()

wait(0.5)

MainFrame.Visible = false
blur:Destroy()
camera.CameraType = Enum.CameraType.Custom
character:WaitForChild(“HumanoidRootPart”).Anchored = false
statsGui.Enabled = true
upgradeGui.Enabled = true

local FadeOutTween = TweenService:Create(MainScreenGui.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {BackgroundTransparency = 1})
FadeOutTween:Play()
FadeOutTween.Completed:Wait()

I have tried looking through the dev forum to find a way to speed up a loading screen and I have tried looking at multiple videos for a better loading screen. Any help is appreciated. Thank you.

-Asher

First, I would swap out each of the “wait(0.5)” with “task.wait(0.5)”, as I’m pretty sure wait() has been deprecated.

Second, have you tried it in Roblox, or only in Studio?

If you’re only in Studio, try going into “File” → “Studio Settings” → “Rendering”, and set the “Editor Quality Level” to “Level 21”. I was having an issue with assets taking a bit to “pop in” in Studio, but in Roblox it was fine. This fixed the Studio delay.

If this doesn’t fix your issue and/or it’s also slow in Roblox, please elaborate more on what exactly is going slowly, and how slow it is.

1 Like

It has not fixed it. The thing that is going by slowly is the assets loading or is there any way to only load important assets like to group certain things as important and others as non important?

1 Like

right now you are loading basically everything in your game when you do game:GetDescendants()
this is not very necessary as services like ReplicatedStorage and ReplicatedFirst are meant for preloading things first for the client.
also ContentProviderService is only really necessary when you want to preload things like images, meshes, or sounds, and it does close to nothing except yield for the client when you load things like parts.
if you wanna speed up the loading times, i suggest that you make a loop that adds all decals/textures, sounds, and meshes inside workspace (not the whole game) into a table and use ContentProvider on the table to preload everything rather than loading everything in your game.

1 Like

Expanding on what Henry said, when you loop through your workspace, you could either add those items by type…

Example:

Something:IsA("MeshPart")

…or if you only need a few specific things preloaded you could also use the “Tag” property to Tag each of the things you want to load. Then, in the loop, you could just look for the Tag you set.

Example:

for _, Item in workspace:GetDescendants() do
    if Item:HasTag("Preload") then
        -- do stuff
    end
end

Let me know if this works/helps. Thanks Henry for the great suggestion!

2 Likes

Thank you guys so much for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.