Preloading ScreenGui Question

Hello, I was making a loading screen for my game, this game has a lot of guis so i wanted them to preload, how should I do this? with PlayerGui? Or with StarterGui?

Use ContentProvider:PreloadAsync()

local ContentProvider = game:GetService(“ContentProvider”)

local thingsToLoad = {} —your screen gui and whatever else

for i, v in pairs(thingsToLoad) do
     ContentProvider:PreloadAsync({v})
end

Oh yes, I think my question is a bit confusing, Im asking how should I load the guis? with PlayerGui, or just load the StarterGui?
This is my actual code:

local function concatTables(t1, t2, t3)
	local combined = {}
	for _, v in pairs(t1) do
		table.insert(combined, v)
	end
	for _, v in pairs(t2) do
		table.insert(combined, v)
	end
	for _, v in pairs(t3) do
		table.insert(combined, v)
	end
	return combined
end

-- Obteniendo todos los descendientes de varias partes del juego

local workspaceDescendants = workspace:GetDescendants()
local replicatedStorageDescendants = game:GetService("ReplicatedStorage"):GetDescendants()
local starterGuiDescendants = game:GetService("StarterGui"):GetDescendants()

-- Combinando todos los descendientes en una sola tabla
local allDescendants = concatTables(workspaceDescendants, replicatedStorageDescendants, starterGuiDescendants)

-- Cargando previamente todos los descendientes
local Countgen = 0

for i, descendant in pairs(starterGuiDescendants) do
Countgen+=1
end

for i, descendant in pairs(starterGuiDescendants) do
	ContentProvider:PreloadAsync({descendant})
	AssetsCount.Text = i.."/"..Countgen
end

Oh, well you should load the playergui, loading the startergui won’t do anything since every player simply replicates the startergui and inserts it.

1 Like

That was the answer i was looking for, thank you!

1 Like

Technically you would put it in Replicated First, the code there compiles first and before anything else, however, I’m sure the other method could work if implemented correctly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.