I am attempting to determine how long it would take for a player to load (for a loading screen), I have looked all over and have found nothing. Any help would be greatly appreciated.
2 Likes
You could first start off with game:IsLoaded() and game.Loaded:Wait() this indicates when most assets are replicated (not loaded tho).
You can then check to see if parts are being added to workspace (e.g if parts are still being added the map isn’t fully loaded)
local function WorkspaceLoaded()
local count = #workspace:GetDescendants() + workspace.Terrain:CountCells()
local old = 0
while count > old do
old = count
task.wait(1)
count = #workspace:GetDescendants() + workspace.Terrain:CountCells()
end
end
And then you can use ContentProvider.RequestQueueSize
to see how many assets still need to be loaded. (this is how loading screens use ‘134 assets loading’ etc)
local function AssetsLoaded()
repeat task.wait() until ContentProvider.RequestQueueSize <= 0
end
All this methods are kinda hacky though and you can find your own through your own game
1 Like
local Workspace = workspace
local Descendants = 1000 --Total number of expected descendants, you can run a loop while in studio to get this count.
local ClockTime = os.clock()
local function OnWorkspaceDescendantAdded(Descendant)
if #Workspace:GetDescendants() < Descendants then return end
print(os.clock() - ClockTime)
end
Workspace.DescendantAdded:Connect(OnWorkspaceDescendantAdded())