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

Loading images quickly?

I've finally gotten into the part of my game that requires loading assets, and I want to do so as efficiently as possible. I understand that there is a preload method, and it will likely be very helpful in the future for images that are to load after the loading screen goes away; however, I've found that some games load images as soon as the game starts without a problem. Having tried to do the same and having a couple friends test it out, mine take time to actually display. Am I missing something? If you guys have any experience in this area, I'd greatly appreciate the help! :)

1 comment

0

Load the GUIs with ReplicatedFirst?

1 answer

The idea of pre loading is that all of the assets are loaded to the client before they are needed so that they are present when they are needed. This is why some GUI images are not present showing an incomplete GUI.

1st you need to add all of the assets to the pre loader 2nd create a loading screen and place it in the replicated first (or a script) 3rd update the loading screen according to the new value.

Here are some links to help loading screen content provider pre loader

Here is my current code I am using atm:- (local script)

local ContentProvider = game:GetService("ContentProvider")
local assetList = {55031729,55031700,48657647,67950784,67950809  --Gui song assets
	,176828159, 221660385, 176827997, 172729074, 144947983, 222392802, 163353836, 222393264,172846809 } 
-- List of game assets


local function LoadAssets(AssetList)
	-- Takes an asset list and preloads it. Will not wait for them to load. 
 
	for _, AssetId in pairs(AssetList) do
		ContentProvider:Preload("rbxassetid://" .. AssetId)
		print("Added:-" .. AssetId)
	end
end

LoadAssets(assetList)

script.Parent:RemoveDefaultLoadingScreen()
 
local screen = Instance.new("ScreenGui")
screen.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
 
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screen
textLabel.Text = "Loading"
textLabel.Size = UDim2.new(1,0,1,0)
textLabel.FontSize = Enum.FontSize.Size14
 
local gameSize = game.ContentProvider.RequestQueueSize
local curSize = 0

while game.ContentProvider.RequestQueueSize > 0  do
	curSize = game.ContentProvider.RequestQueueSize
	if curSize < 0 then curSize = 0 end
	curSize = math.abs(gameSize - game.ContentProvider.RequestQueueSize)
	textLabel.Text = "Loading " .. gameSize .. "/" .. curSize
	print(textLabel.Text)
	wait()
end

while curSize < gameSize do
curSize = curSize +1
textLabel.Text = "Loading " .. gameSize .. "/" .. curSize
wait(1)
end

screen.Parent = nil

sorry its not commented it is a work in progress and demonstrates the basic usage of the loading screen.

Hope this helps

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