ContentService not working for trying to find number of loaded assets

I have a problem that I can’t seem to fix right now. And yes, I’ve been to about 5 different DevForum discussions about it. I have a script that checks certain assets and waits for them to be loaded, but it doesn’t seem to be working. I’m putting the script and a link that I found below:

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")
ReplicatedFirst:RemoveDefaultLoadingScreen()

local assetsLoaded = 0
local assetsToLoad = {
	game.Workspace:GetDescendants(),
	player:WaitForChild("PlayerGui"):WaitForChild("MainGui"):GetDescendants(),
	game.ReplicatedFirst:GetDescendants(),
	game.ReplicatedStorage:GetDescendants()
}
print(assetsToLoad)

for _, asset in pairs (assetsToLoad:GetChildren()) do
	ContentProvider:PreloadAsync({asset})
		assetsLoaded+=1
		script.Parent.LoadingFrame.Background.Progress.Size= UDim2.new(#assetsToLoad/assetsLoaded,0,0,0)
end

Assets are not parts. They are things uploaded to roblox such as meshes, images, videos, and audio.

Oh I didn’t even put the error. The error was “Unable to cast Array to Content”
@myaltaccountsthis is that going to be a problem with the performance, or is it just saying I’m using the wrong word?

It’s not necessary to call :GetChildren() on assetsToLoad as it is already a table which you can loop through using pairs(). You do not need to pass in {asset} inside the ContentProvider:PreloadAsync() function, instead just pass the asset variable without the {} around it.

With doing that, there’s no errors, but it doesn’t work either.

ContentProvider won’t load things that aren’t Content (assets).

Also, you have to combine these tables, but you might as well list all your assets.

Change it to this:

local assetsToLoad = {
    -- list actual Content or assets here
}

So if I have nothing that’s been uploaded to Roblox, does that mean that using this method for a loading screen just won’t work?

I don’t think it will try to load them which would cause it to never finish loading everything

How do people normally show loading, like, a good example, Infinite Autocorrect, where it shows every “asset”? Is that not every part in the game then?

You can also put Decals, Animations, and Sounds in the table