Loading screen error (PreloadAsync, Unable to cast to Array)

I am working on this loading screen that tells the player what assets are being loaded, yet I keep getting an error on Line 19.

Unable to cast to Array - Client - Load:19

I tried changing it with a callback function like it said in this post, but it didnt seem to work. I read through ContentProvider:PreloadAsync's page yet I still can’t seem to find a fix for the error…

Here is my script, any help?

--// services
local TweenService = game:GetService("TweenService")

--// Establish new loading-coregui 
local RF = game:GetService("ReplicatedFirst")
RF:RemoveDefaultLoadingScreen()

local newLoading = script.Parent
newLoading.Parent = game.Players.LocalPlayer.PlayerGui

--// Load assets and stuff
local contentProvider = game:GetService("ContentProvider")
toLoad = game.ReplicatedFirst:GetDescendants()

local loadingAsset = script.Parent.black_Background.loadingAsset
local total = #toLoad
for i, v in pairs(toLoad)  do
	loadingAsset.Text = "Loading: "..i.. "/"..total.." "..v.Name
	contentProvider:PreloadAsync((v))
end

wait(1)
RF:GetDescendants().Parent = game.Workspace
loadingAsset.Text = "Assets loaded"
wait(2)
TweenService:Create(
	loadingAsset,
	TweenInfo.new(1),
	{TextTransparency = 1}
):Play()


--// variables
local Credit = script.Parent.black_Background.Credit
local black_Background = script.Parent.black_Background

--// funcs
function typewrite(TextLabel,text) -- parameters (where text goes, what text says)
	for i = 1,#text do
		TextLabel.Text = string.sub(text,1,i) 
		wait() 
	end
end

--// main

wait(1)
typewrite(Credit.Text,"Beneath Games")


TweenService:Create(
	black_Background,
	TweenInfo.new(1),
	{BackgroundTransparency = 1}
):Play()

edit

tried this still same error

--// services
local TweenService = game:GetService("TweenService")

--// Establish new loading-coregui 
local RF = game:GetService("ReplicatedFirst")
RF:RemoveDefaultLoadingScreen()

local newLoading = script.Parent
newLoading.Parent = game.Players.LocalPlayer.PlayerGui

--// Load assets and stuff
local contentProvider = game:GetService("ContentProvider")
toLoad = game.ReplicatedFirst:GetDescendants()

local loadingAsset = script.Parent.black_Background.loadingAsset
local total = #toLoad
for i, v in pairs(toLoad)  do
	loadingAsset.Text = "Loading: "..i.. "/"..total.." "..v.Name
	contentProvider:PreloadAsync((v), function()
print("loaded asset")
end)
end

wait(1)
RF:GetDescendants().Parent = game.Workspace
loadingAsset.Text = "Assets loaded"
wait(2)
TweenService:Create(
	loadingAsset,
	TweenInfo.new(1),
	{TextTransparency = 1}
):Play()


--// variables
local Credit = script.Parent.black_Background.Credit
local black_Background = script.Parent.black_Background

--// funcs
function typewrite(TextLabel,text) -- parameters (where text goes, what text says)
	for i = 1,#text do
		TextLabel.Text = string.sub(text,1,i) 
		wait() 
	end
end

--// main

wait(1)
typewrite(Credit.Text,"Beneath Games")


TweenService:Create(
	black_Background,
	TweenInfo.new(1),
	{BackgroundTransparency = 1}
):Play()

preloadasync needs an array, not an instance, so try
contentProvider:PreloadAsync(({v}))

It would actually be ({v}) instead of (({v})).

yeah i saw that, I looked at
image

and didnt correct for it

sorry for seeing this late, i just had to do this

--// Establish new loading-coregui 
local RF = game:GetService("ReplicatedFirst")
RF:RemoveDefaultLoadingScreen()

local newLoading = script.Parent
newLoading.Parent = game.Players.LocalPlayer.PlayerGui

--// Load assets and stuff
local contentProvider = game:GetService("ContentProvider")
toLoad = game.ReplicatedFirst:GetDescendants()

local loadingAsset = script.Parent.black_Background.loadingAsset
local total = #toLoad
for i, v in pairs(toLoad)  do
	loadingAsset.Text = "Loading: "..i.. "/"..total.." "..v.Name
	contentProvider:PreloadAsync({v}, function()
print("loaded asset")
end)
end
1 Like