Itz_N3p1
(Itz_N3p1)
March 14, 2021, 8:28pm
#1
Hello! Im trying to make a percent loading screen, and I cant figure out this one problem.
preload = workspace:WaitForChild("House"):GetDescendants()
assets = {
preload
}
ContentProvider:PreloadAsync(assets, function()
preloadedSize += 1
end)
How would I put all the preload items(GetDescendants()) into the assets table?
Thanks in advance.
GetDescendants returns an array, so just set that as the assets
table.
local assets = workspace:WaitForChild("House"):GetDescendants()
ContentProvider:PreloadAsync(assets, function()
preloadedSize += 1
end)
2 Likes
Itz_N3p1
(Itz_N3p1)
March 14, 2021, 8:34pm
#3
When I try that this is what appears on my screen.
Here’s a bit more of the code, not sure how much of a help it will be though.
preload = workspace:WaitForChild("House"):GetDescendants()
local preloadSize = #preload
local preloadedSize = 0
ContentProvider:PreloadAsync(preload, function()
preloadedSize += 1
end)
RS.Heartbeat:Connect(function()
local n = ContentProvider.RequestQueueSize
local progress = preloadedSize / preloadSize
local percent = (progress*100)
print(percent, preloadedSize)
subtitle.Text = percent.."% Preloaded"
end)
preloadSize = 1620
and percent and preloadedSize print this
After every frame, you should update the preload
variable.
RS.Heartbeat:Connect(function()
preload = workspace:WaitForChild("House"):GetDescendants()
Basically what @myaltaccountsthis said is probably what’s going on.
Bruh, it’s probably because not everything under house is an asset, so only 15 things get loaded. The percent is right.
1 Like
Itz_N3p1
(Itz_N3p1)
March 14, 2021, 8:44pm
#6
Most of them are assets
Im pretty sure out of 1620 not just 15 of them are assets
1 Like
Those are just parts. Assets are things uploaded to roblox such as decals, audio, models, and animations. They contain an id.
1 Like
Itz_N3p1
(Itz_N3p1)
March 14, 2021, 8:51pm
#8
I see, how would I make it load the actual assets then? because currently its doing (15/1620)*100
You can use Instance:IsA()
Just iterate through the descendants, then have an if statement
it should look like if v:IsA("Decal") or v:IsA("Sound") then
add different types as needed
1 Like
Itz_N3p1
(Itz_N3p1)
March 14, 2021, 9:10pm
#10
Im getting closer, but its still off
local coolTable = {}
for _,loadingassets in pairs(workspace:WaitForChild("House"):GetDescendants()) do
if loadingassets:IsA("Sound") or loadingassets:IsA("Texture") or loadingassets:IsA("Decal") then
table.insert(coolTable,loadingassets)
end
end
print(#coolTable)
its prints 544
so its now 15/544