Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my loading screen not printing the correct numbers?

I am trying to make a loading screen, then on a text label I want it to say "amountOfAssetsLeftToLoad / AllTheAssetsInTheGame"

my code:

local ok = 0
local cp game:GetService("ContentProvider")
for i,v in pairs(game.Workspace:GetDescendants()) do
	ok = ok + 1
end

wait()

while wait() do
	local k = game:GetService("ContentProvider").RequestQueueSize
	print(k / ok .. "/" .. ok)
end

This seems to print things like "9/1" and stuff. I have 3k parts in my game so its not right.

1 answer

Based on roblox wiki, you shoudn't use ContentProvider.RequestQueueSize to make loading screens, instead you should use ContentProvider:PreloadAsync


You script just needs to wait for the workspace to load, adding a wait() befor the first exectution should fix it.

local ok = 0
local cp game:GetService("ContentProvider")
wait(0.5)
for i,v in pairs(game.Workspace:GetDescendants()) do
    ok = ok + 1
end

wait()

while wait() do
    local k = game:GetService("ContentProvider").RequestQueueSize
    print(k / ok .. "/" .. ok)
end

Please mark the answer as accepted if it works

2 comments

0

what is the other way of doing it?

0

its on the link of ContentProvier.RequestQueueSize

This discussion is preserved as it was. New answers, comments, and votes are closed.