I’m trying to make a loading screen gui with the assets that need to be loaded. I’m not going to even think about doing fake loading screens.
local function spinImage()
while wait() do
script.Parent.Frame.ImageLabel.Rotation = script.Parent.Frame.ImageLabel.Rotation +2
end
end
local contentProvider = game:GetService("ContentProvider")
local toLoad = workspace:GetDescendants()
local total = #toLoad
spinImage()
for i,v in pairs(toLoad) do
contentProvider:PreloadAsync(v)
script.Parent.TextLabel.Text = "Loading Assets : " .. i .. "/" .. total
end
I need it explained / fixed simply, to help others and myself.
Just like @Thedagz said, PreloadAsync() accepts an array in the parameter and what I can see from your code is that you only added one object, maybe you could do contentProvider:PreloadAsync(toLoad) because toLoad is an array contained with all of the descendants of the workspace so that should work.
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
local contentProvider = game:GetService("ContentProvider")
script.Parent.Loading:Play()
while wait() do
local toLoad = workspace:GetDescendants()
local preload = contentProvider:PreloadAsync(toLoad)
script.Parent.TextLabel.Text = "Loading Assets : " .. contentProvider.RequestQueueSize
if contentProvider.RequestQueueSize == 0 then
script.Parent:Destroy()
end
end
``` I got this script at the moment. I change things alot.