Preloading assets -- best method?

How do people preload their assets nowadays? Instead of a huge asset table, I collect ids in the datamodel. I use a hacky function to go thru an instance’s descendants to see if they are of a particular class, and if that’s the case then relevant class content ids are added to a table. After all ids have been collected, this table is fed to ContentProvider one by one. This is quite a lengthy function because roblox hasn’t exposed their own asset collector in the api (I think…?)

I really don’t like this method. It works, yes, but it seems overly complicated, and if new classes are added the function has to be updated. Is this standard or am I going about it wrong?

Just go through all your Assets (Services) from your game. (Make sure you are using a local script in Replicated first or StarterPlayer.)

local cp = game:GetService("ContentProvider")

--- Preload Game ---
for _,service in pairs(game:GetChildren()) do
	pcall(function()
		warn("Loading: "..service.Name)
		cp:PreloadAsync({service})
		wait()
	end)
end

(I know, kinda late response but hope I was able to help anyway)

1 Like