okay so i ended up finding out about the existence of ContentProvider
though i’m not sure whether i did something wrong, because the game seems to load for pretty long
local contentProvider = game:GetService("ContentProvider")
local ui = script:WaitForChild("LoadingScreen"):Clone()
local assets = game:GetDescendants()
local plr = game:GetService("Players").LocalPlayer
local plrGui = plr.PlayerGui
ui.Parent = plrGui
local quotes = ui:WaitForChild("Quotes")
local quoteChances = {
["I rebel, therefore I exist."] = 10,
["Question everything."] = 10,
["Live fast, die young."] = 10,
["We are all mad here."] = 10,
["I am the storm."] = 10,
["Normal is boring."] = 10,
["Reality is a prison."] = 10,
["Die with memories, not dreams."] = 10,
["Embrace the chaos."] = 10,
["Silence is the loudest scream."] = 10
}
function SelectQuote()
local totalChance = 0
for _,chance in quoteChances do
totalChance += chance
end
local rng = math.random(1,totalChance)
for quote, chance in quoteChances do
rng -= chance
if rng <= 0 then
return quote
end
end
end
if not game:IsLoaded() then
plr:SetAttribute("Loaded", false)
repeat
quotes.Text = SelectQuote()
task.wait(5)
until contentProvider:PreloadAsync(assets)
end
task.wait(1)
plr:SetAttribute("Loaded", true)
ui:Destroy()
if not game:IsLoaded() then
plr:SetAttribute("Loaded", false)
coroutine.wrap(function()
while not game:IsLoaded() do
quotes.Text = SelectQuote()
task.wait(5)
end
end)()
local success, err = pcall(function()
contentProvider:PreloadAsync(assets)
end)
if not success then
warn("Failed to preload asset: " .. err)
end
end
if not game:IsLoaded() then
plr:SetAttribute("Loaded", false)
for i = 1, #assets do
local asset = assets[i]
ContentProvider:PreloadAsync({asset})
end
end