I have loading screen. But the problem is that I have trees on the map. And there are many of them. They are of the same type, it is enough to load one tree so that the rest have already been loaded.
The loading screen is very slow because of the trees, i.e. it loads 17,000 objects, although 10,000 of them are trees. The bottom line is that trees without a loading screen appear very quickly, and I don’t see the point for the loading screen to load them all and take a lot of time to load. Is it possible to filter these trees somehow? so that they are not in the list for downloading assets.
just in case, I’ll say that all trees have the same name
local contentProvider = game:GetService("ContentProvider")
local UI = script:WaitForChild("ScreenGui"):Clone()
repeat wait() until game:IsLoaded()
local assets = game.Workspace:GetDescendants()
local maxAssets = #assets
local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
UI.Parent = plrGui
UI:WaitForChild("Frame"):WaitForChild("TextLabel").Text = math.floor(0 / maxAssets * 100).."%"
wait(0.5)
UI.Frame:WaitForChild("ImageButton").Activated:Connect(function()
UI:Destroy()
script:Destroy()
end)
for i, assetToLoad in assets do
contentProvider:PreloadAsync({assetToLoad})
UI:WaitForChild("Frame"):WaitForChild("TextLabel").Text = math.floor(i / maxAssets * 100).."%"
print(i.." "..maxAssets)
end
wait(1)
UI:Destroy()