Checking how many parts have rendered on the client

Henlo(what I usually say when I want to say hello),

I made a progress bar, and I want it to display how many parts have rendered in on the client.

The problem is, I don’t know how I could get how many parts have rendered in on the client.

Any methods/ideas/suggestions?

1 Like

What exactly do you mean by rendered? Do you mean how many parts are currently visible on the screen or how many parts have been replicated to the client?

I think you may be looking for RequestQueueSize. This shows the amount of items which are being loaded.
This value decreases as more assets are loaded, therefore the queue size decreases.

3 Likes

replicated

I mean in that case you can just :GetChildren() on Workspace (or wherever) because the client can only access whats replicated to it from the server.

However, if you’re trying to make a loading screen then that’s a really inefficient way of doing so and it won’t work. I recommend doing what @uJordy said.

Please refrain from using RequestQueueSize. The number shown is not an accurate way to determine replication or amounts of assets left to load for a loading screen. I recommend having an array of assets (decals, images, meshes, animations, etc.) and using the PreloadAsync function on the array of assets and you can create your own system to see how many assets have loaded from the array.

1 Like

That are waiting to be*

An asset being in the preload queue doesn’t mean it’s been downloaded, that means it’s waiting to be downloaded. When the number goes down, the client begins downloading the asset.


@Faultsified Parts don’t need to be downloaded. Passing an entire array full of your assets to PreloadAsync will also not help you to determine how many assets have been downloaded because the thread will yield until all assets have finished preloading.

What you can do instead is have an array of all your assets and put each item in a single-entry array passed to PreloadAsync - this is a better way to make loading screens because you can actually yield until that one asset is marked as downloaded.

This would be a good solution if OP was asking how to create a loading screen for assets, though the question pertains to parts and not assets, making this moot.


So, simple answer: there is no way to check how many parts have been rendered on the client. Even if there is, it’s probably an internal that you can’t access. Parts don’t need to be downloaded, they just need to be replicated - skip trying to check how many parts have been rendered and instead focus on what assets need to be downloaded (anything that has an AssetId parameter).

2 Likes

I’m working on a brickbattle game and run a count at the beginning and end of the round. Here is the script I use. Hope this helps of gives some ideas.

local pa = {}
for _,p in pairs(workspace:GetDescendants()) do
if p:IsA("BasePart") then
table.insert(pa, p)
end
end

local StartingPartsCount = #pa
local EndingPartsCount = #pa

print(“Start of Round Data”)
print("Starting Value "…StartingPartsCount)

2 Likes

The use cases here are different. OP is making a progress bar and wants to check how many parts have rendered on the client via script, which there’s no API for that.

Counting parts is moot because the instances themselves will exist; the associated assets won’t be though if they’re being used for the first time. If you’re using that for a statistic based on it the map changes at the start of a round and the end of a build battle carnage, that’s fine but that’s also a different topic altogether.