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

RequestQueueSize loading bar is freezing, anybody know how how to fix this?

What I'm trying to do I'm trying to make a loading screen that show the amount of assets left, and has a loading bar.

My current scripts + Structure Script #1: Injects GUI into player (Local Script)

local gui = script.LoadingGUI

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	gui:Clone().Parent = player.PlayerGui
end)

Script #2: What runs the loading bar + screen (Script)

local PlayerGUI = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local StarterGui = game.StarterGui
local frame = script.Parent.Frame
local base = frame.Bar
local bar = base.intBar
local indicator = base.loadingtext
local queue = game.ContentProvider.RequestQueueSize

PlayerGUI:SetTopbarTransparency(1) -- Makes Topbar Invisible

wait()
pcall(function()
    local starterGui = game:GetService('StarterGui')
    starterGui:SetCore("TopbarEnabled", false)
end) --Disable Topbar Buttons

game.ReplicatedFirst:RemoveDefaultLoadingScreen() -- Disables Roblox Loading Screen

while wait() do
	indicator.Text = "LOADING ASSETS... (" .. queue .. ")"
	bar.Size = UDim2.new(1/queue,0,1,0)
	if queue == 0 then
		indicator.Text = "ASSETS LOADED!"
		bar.Size = UDim2.new(1,0,1,0)
		wait(1)
		frame:TweenPosition(UDim2.new(0,0,1,0))
	end
end

Structure : Code Block so it can have lines

--> Server Script Sevice
---> LoadingGUI (Script, Script #1)
----> LoadingGUI (ScreenGUI)
-----> Loading Screen (Local Script, Script #2)
-----> Frame
------> Bar (used for a outline of my loading bar)
-------> intBar (loading bar that moves right)
-------> loadingtext (Show how many assets left to load)
------> BG (background image for my Loading Screen)

I really just don't know what to do here, it just freezes up at a number, or it says assets loaded and ends the loading screen

1 answer

✓ Accepted answer

You have to make sure to check how much items are left in the queue within the while loop, otherwise your queue is always going to be the variable it is at the start of the game.

An easy fix is to put local queue = game.ContentProvider.RequestQueueSize within your while loop.

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