I dont want to have a fake loading screen for looks that just make players wait , i actually want to wait for things to load. How do i do that? Maybe thats a dumb question cause yall dont know whats in my game but how is it generally made? How do i check if assets are loaded?
you can use game.Loaded or ContentProvider, there might be other ways idk
Hello ![]()
I found a post that might help you How to make a loading screen that is actually optimized
Pretty nice introduction to loading screens..
I made a example one here it is
WHAT IT DOES:
-
Preload critical assets,
-
wait for client init flags,
-
confirm the server is ready,
-
if StreamingEnabled, request nearby map streaming.
HOW TO USE:
Drop the LocalScript below into StarterPlayerScripts, wire your UI in the placeholders, create ReplicatedStorage.InitFlags (BoolValues your scripts flip to true), and add a RemoteFunction named ServerReady that returns true when the server is fully initialized.
-- LocalScript (StarterPlayerScripts)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local player = Players.LocalPlayer
local SHOW_TIMEOUT_SEC = 20
local ASSET_CHUNK = 50
local function beginLoadingUI() end
local function updateLoadingUI(_) end
local function endLoadingUI() end
local function shouldSkip() return false end
local function waitForCharacter()
if player.Character and player.Character.PrimaryPart then return end
player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")
end
local function collectAssets()
local list = {}
local function add(container)
if not container then return end
for _, inst in ipairs(container:GetDescendants()) do
if inst:IsA("Decal") or inst:IsA("Texture")
or inst:IsA("MeshPart") or inst:IsA("SpecialMesh")
or inst:IsA("SurfaceAppearance") or inst:IsA("Sound")
or inst:IsA("ParticleEmitter") or inst:IsA("Trail")
or inst:IsA("Animation") or inst:IsA("ImageLabel")
or inst:IsA("ImageButton") then
table.insert(list, inst)
end
end
end
add(ReplicatedStorage)
add(Workspace)
return list
end
local function preloadAssets(assets, timeoutSec)
local start = os.clock()
for i = 1, #assets, ASSET_CHUNK do
local chunk = {}
for j = i, math.min(i + ASSET_CHUNK - 1, #assets) do
table.insert(chunk, assets[j])
end
local ok = pcall(function() ContentProvider:PreloadAsync(chunk) end)
if not ok then break end
updateLoadingUI((i + ASSET_CHUNK - 1)/math.max(1, #assets))
if shouldSkip() or (os.clock() - start) > timeoutSec then return end
RunService.Heartbeat:Wait()
end
end
local function waitForInitFlags(timeoutSec)
local folder = ReplicatedStorage:FindFirstChild("InitFlags")
if not folder then return end
local start = os.clock()
while true do
local allReady = true
for _, v in ipairs(folder:GetChildren()) do
if v:IsA("BoolValue") and v.Value ~= true then
allReady = false
break
end
end
if allReady or shouldSkip() or (os.clock() - start) > timeoutSec then return end
RunService.Heartbeat:Wait()
end
end
local function waitForServerReady(timeoutSec)
-- server connection
local remotes = ReplicatedStorage:FindFirstChild("Remotes") or ReplicatedStorage
local rf = remotes:FindFirstChild("ServerReady")
if not rf then return end
local start = os.clock()
while true do
local ok, ready = pcall(function()
-- server connection
return rf:InvokeServer()
end)
if (ok and ready) or shouldSkip() or (os.clock() - start) > timeoutSec then return end
task.wait(0.25)
end
end
local function requestStream(timeoutSec)
if not Workspace.StreamingEnabled then return end
waitForCharacter()
local root = player.Character and player.Character.PrimaryPart
if not root then return end
local start = os.clock()
while (os.clock() - start) <= timeoutSec do
Workspace:RequestStreamAroundAsync(root.Position)
if shouldSkip() then break end
task.wait(0.5)
end
end
beginLoadingUI()
preloadAssets(collectAssets(), SHOW_TIMEOUT_SEC)
waitForInitFlags(SHOW_TIMEOUT_SEC)
waitForServerReady(SHOW_TIMEOUT_SEC)
requestStream(SHOW_TIMEOUT_SEC)
endLoadingUI()
If your game uses data stores, you can fire a remote event to the player once all of their data has been loaded on the server.
You can also put a localscript with script.Parent:RemoveDefaultLoadingScreen() in ReplicatedFirst to remove the default loading screen and show your own loading screen.
i used actors to get <10s loading times. study up on multithreading if you haven’t already.
if you have, put an actor under replicatedfirst, then another actor under the screengui that the loading screen is in, put a script inside the replicatedfirst actor that messages another script to load assets individually. the actor in question should look like this.
then, the actor in the gui should look like this. (ignore the directories.)
unfortunately, it would be way too long to explain what each script does, but basically the “trigger” messages the init script, which then sends a message to the other asset loading scripts. of course, wrap the init script messaging in a pcall so it doesn’t infinite load. for the gui loader, the trigger script should message it, like loadingAssets to open the loading screen, and completedLoading to close it
i definitely did not do a good job at explaining this, but sadly you’ll have to do your own digging for a true optimized loading screen.
edit: the pcall statement in the init script should message the trigger script to remove the loading screen so the player can actually play the game when it does fail.

