Loading script no longer reliably functioning?

For whatever odd reason, this my LoadingHandler, which is within ReplicatedFirst, was always working fine, up until recently when it just stopped working right before repeat task.wait() was called. I verified this as I was able to detect errors with fetching assets via ContentProvider, however, I did some testing and game:IsLoaded() is true alongside the RequestQueueSize being 0. There is no actual errors or warnings, so I honestly have no idea why this script doesn’t work much anymore. (it works SOMETIMES)

game:GetService("ReplicatedFirst"):RemoveDefaultLoadingScreen()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local a = false

script.Loader.Parent = game.Players.LocalPlayer.PlayerGui

task.wait(5)

local success, err = pcall(function()
    for _, child in pairs(game.MaterialService:GetDescendants()) do
        game:GetService("ContentProvider"):PreloadAsync({child})
    end

    for _, child in pairs(workspace:GetChildren()) do
        game:GetService("ContentProvider"):PreloadAsync({child})
    end

    for _, child in pairs(game.ReplicatedStorage:GetChildren()) do
        game:GetService("ContentProvider"):PreloadAsync({child})
    end
end)

repeat task.wait() until game:GetService("ContentProvider").RequestQueueSize == 0 and game:IsLoaded()
1 Like