Server print workspace descendants but client is only printing one

My script is ment to print each asset inside of workspace. My localscript (the one that has to work) only prints the first object, however, my server script test prints all of them. I have no idea why.

Local script

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

local ContentProvider = game:GetService("ContentProvider")
local LoadingScreen = script:WaitForChild("LoadingScreen"):Clone()

local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

LoadingScreen.Parent = PlayerGui

local Background = LoadingScreen:WaitForChild("Background")
local AssetBar = Background:WaitForChild("AssetBar")
local Title = Background:WaitForChild("Title")

local Assets = {}
----------
for _, Object in pairs(workspace:GetDescendants()) do
	table.insert(Assets, Object)
	print(Object.Name)
end
----------
for i = 1, #Assets, 1 do
	local Asset = Assets[i]
	ContentProvider:PreloadAsync({Asset})
end

wait(10)
LoadingScreen:Destroy()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

script:Destroy()

That is because not everything has been replicated to the client yet, you’ll have to wait for them to be added.
More information can be found here: How to get LocalScripts to wait for workspace to completely load - #9 by woot3

1 Like

Clients cannot read descendants of workspace, AFAIK. You should use a remote function to return the names of the items inside the workspace; I am uncertain if the instances themselves can be passed over. Even if you can, the client can only modify them locally anyway.

Also what exactly are you trying to do? Why are you trying to preload the assets in workspace? They already exist and are loaded in when the game loads, you only need to preload assets such as decals and sounds.

Idk, I see comments saying use this service for loading screens.

Instances and objects can be sent over as long as it exists on both server and the client, otherwise its reference will return nil.

Yes, ContentProvider is used to load in assets for the client to use and the main use is a loading GUI.

Usually one would use ContentProvider for Decals/Images & Sounds. You can also preload animations (AFAIK) and other things, but the main use is to load images and sounds. This is useful for UI and ambient sounds throughout the game that are loaded on the client to not play through to all players.