No idea why my loading screen displaying loading assets < 0

Yes, I made a loading screen. But it sometimes shows me negative value. Is it a bug?
How do I fix this?

local Service = game:GetService("ContentProvider")
local Number = Service.RequestQueueSize
script.Parent.Parent.Enabled = true
while true do
	local N = Service.RequestQueueSize
	script.Parent.LoadingBar.Bar.Bar.Size = - N)/Number,0,1,0)
	if (Number - N)/Number ~= 1 then
	script.Parent.Assetsleft.Text = "LoadingAssets("..(Number - N).."/"..Number..")"
		script.Parent.Assetsleft.Text = "Loaded!"
		local Service = game:GetService("TweenService")
		local Info =,Enum.EasingStyle.Quart,Enum.EasingDirection.In,0,true,0)
		local Goal = {}
		Goal.BackgroundTransparency = 0
		local Tween = Service:Create(script.Parent.Parent.Parent.Flash.Back,Info,Goal)
		script.Parent.Parent.Enabled = false
		script.Disabled = true
1 Like

Can you give me game link? I want check it.

Here it is, this is the game.
Notice that the loading screen is pretty fast.

Another classic redundant use of while true do. Let me fix that and give some context:

local ContentProvider = game:GetService("ContentProvider")
local TweenService = game:GetService("TweenService")
local Current, Number = ContentProvider.RequestQueueSize, ContentProvider.RequestQueueSize
local Info =, Enum.EasingStyle.Quart, Enum.EasingDirection.In, 0, true, 0)
local Goal = {BackgroundTransparency = 0}
local Tween = TweenService:Create(script.Parent.Parent.Parent.Flash.Back, Info, Goal)

script.Parent.Parent.Enabled = true

while (Number - Current) / Number >= 1 do -- sometimes numbers are inaccurate
    script.Parent.LoadingBar.Bar.Bar.Size = - N)/Number,0,1,0)
    script.Parent.Assetsleft.Text = "LoadingAssets("..(Number - N).."/"..Number..")"
    Current = ContentProvider.RequestQueueSize

script.Parent.Assetsleft.Text = "Loaded!"
script.Parent.Parent.Enabled = false
-- script.Disabled = true -- redundant

  • while loops functions like any loop with an if statement checking if it’s true, then run
  • Division by 0 is impossible
  • Missing detail on when ContentProvider is preloading
  • Possible both numbers started on 0

Oh yeah.It stuck when I join the game my assets at 0 and I can play.Hmmm

Huh?! It never happened before?! I have tested it a lot.

Idk maybe for some of the server.When I join it stuck

Maybe try it again. I didn’t know that it would happen on you.
Oh it also happened on me too.

Perhaps the temporary fix is to use math.clamp to limit the range of the number from 0 to math.huge. However, the question is when is ContentProvider used to load assets?

What do you mean? I didn’t use any preload function.

Would you mind if you read this?

Depending how many new assets and preloaded assets you have, there seems to be an error with the calculation of (Number - N) / Number. We still don’t know how many other assets are in. Also there might be momentary occurences where the RequestQueueSize is 0 at the very beginning.

How do I prevent RequestQueueSize at 0 on starting game?
Should I add a wait(0.25) on the first line?

I’m not quite sure myself where to look to improve it. Try making sure that RequestQueueSize > 0.

The best fix to this is not to use RequestQueueSize at all. It is an arbitrary number that describes how many assets are queued to download. You are not supposed to use this for loading screens; depending on how aaset-intensive your game is, this number can be very large and keep players in loading screens for a while which is terrible UX.

What you should be doing instead is making use of PreloadAsync, only preloading the assets players need to have first thing upon entering (e.g. main menu icons, music and audio) and making your number based on your manufactured queue list. Downloading should otherwise be streamed in the background.