Do I understand correctly, you are trying to make loading take more time?!
This is due to the fact that Parts do not require preloading.
From the top of my head, the things that require preloading are:
- Textures
- Decals
- MeshParts
- UnionOperations
…and other things. You’re probably trying to preload a group of Parts, which is why it is so fast.
no, it’s just strange whenever you join the game, let’s say the game has 100 parts, the gui only says 2 (using @Starveldt’s script) and then the gui closes.
I have 31 parts, two of then are the spawn location and the baseplate. the rest are just test parts. they aren’t in a group. any other idea?
edit: ah. I forgot, you said parts, im going to try decals now.
edit 2: Now it changes to 3, I put decals in every single part.
That’s why.
Parts don’t need preloading. If you wanna fix this issue, it’s just about changing your toLoad array.
--note: it already replaces the default loading gui
--// Variables \\--
local loadingScreen = script.ScreenGui
loadingScreen.Parent = game.Players.LocalPlayer.PlayerGui
--// Loading \\--
local contentProvider = game:GetService("ContentProvider")
-- ex.
local map = workspace:WaitForChild("Map")
local loadFilter =
{
UnionOperation = true;
MeshPart = true;
Texture = true;
Decal = true;
}
local toLoad = {}
for _, descendant in map:GetDescendants() do
if loadFilter[descendant.ClassName] then
table.insert(toLoad, descendant)
end
end
local total = #toLoad
local loaded = 0
-- Wrap this in a protected call.
local success, error = pcall(contentProvider.PreloadAsync, contentProvider, toLoad, function()
loaded += 1
loadingScreen.cs.LoadingName.Text = "loading: " .. loaded .. "/" .. total .. " " .. toLoad[loaded].Name
loadingScreen.cs.BarBG.Bar.Size = UDim2.fromScale(loaded / total, 1)
print("Loaded", toLoad[loaded])
end)
if not success then
warn("Could not preload assets:", error)
end
--// Finished Loading \\--
task.wait(1)
loadingScreen:Destroy()
it does the exact same thing
character limit
That’s because there is literally that much to preload. You only have 3 things that can be preloaded in your ‘Map’ instance.
The script you sent earlier uses GetChildren. This doesn’t iterate through children of children.
Make sure you know the difference between GetDescendants and GetChildren.
so then how would I change the script so it loads children of children?
Summary
im sorry if im waisting your time
Use GetDescendants like I said.
To be clear PreloadAsync
only preloads “stuff with asset id”.
PreloadAsync can load instances, though if the ‘asset id’ is empty it will throw a warning in the output.
(–Was thinking of invalid ids, my bad)
It will load only instances with custom ids.
I tried multiple ways of using getdescendants and get children,
but the only one that worked was the one you used in the current script. it still only loads 3 parts. this is the gui:
then after 1 second the gui closes.
It’s because there is nothing to preload in your other decals, if they are assumedly empty.
so then how would I test to see if the script actually works?
meshparts? unions?
The script does work if it can succesfully preload the 3 decals that have actual content in them, but if you do need to see if it works, add multiple decals with different asset ids into your map.
Add this before PreloadAsync
local toLoad = {}
for i = 1, 100 do
table.insert(toLoad, "rbxthumb://type=Avatar&w=100&h=100&id=" .. math.random(1,1000000))
end
(From roblox wiki)
thanks! it works
you earned a solve