Loading Screen not Loading

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? A loading screen

  2. What is the issue? I get an error saying Unable to cast to Array

  3. What solutions have you tried so far? I’ve checked the PreloadAsync() API and looked over some posts but none of them have helped me

here’s the script (under the GUI in StarterGui)

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

-- variables --
local loadingScreen = script.Parent
local itemsToLoad = workspace:GetDescendants()

-- code --
for i,v in pairs(itemsToLoad) do
	loadingScreen.MainFrame.TextLabel.Text = "Loading... "..math.floor(i/#itemsToLoad).."%"
	loadingScreen.MainFrame.LoadingFrame.LoadingBar.Size = UDim2.new(i/#itemsToLoad, 0,1,0)
	ContentProvider:PreloadAsync((v))
end

print("finished loading")

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

3 Likes

PreloadAsync takes a table as an argument, but you’re passing an actual object to it instead.

ContentProvider:PreloadAsync({v}) --//load a single item at a time 
2 Likes