Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I check if a folder has fully loaded in?

I'm looking for an api reference or a basic idea of how I would work this (basically a path that I can bring myself down)

I have already seen ContentProvider.RequestQueueSize. Not what im looking for as I could be loading in multiple plots at once.

Is there a smaller version of that where I could get the queue size of a single folder?

Edit: I have tried ContentProvider.RequestQueueSize for this but it won't work because my game automatically loads in the top 25 plots or so every 3 minutes. I don't want the script to get confused with those plots also

1 answer

It matters in which situation, if you are afraid that the folder is not loaded before script runs and it contains stuff that does not needed to be seen in studio (ex. Modules) then you can put the folder into ReplicatedStorage as everything in there loads before any script runs.

Else for your plots whatever those are, there is not an API to do like Instance:WaitForPath but you can create 'similar' function which can only be used in case when you know that there will be 25 plots, basically it will wait for folder until it contains given amount of children inside of it.\n Here is example of how i would implement that:

--/sry the name..
local function WaitUntilInstanceContainsGivenAmountOfChildren(Instance, Amount)
	--/Return if all already are there
	--/Gets amount of children and checks if amount of them
	--\is same as or higher than given [Amount]
	if (#Instance:GetChildren() => Amount) then
		return
	end

	--/This will create a bindable event which script will yield
	--\until amount of children in the instance is [Amount]
	local Signal = Instance.new('BindableEvent')

	--/Now there is an event ChildAdded when fires when child
	--\is added into the instance, you can use it here, make
	--\sure to disconnect the connection after to prevent memory leaks
	--/It will fire signal if amount of children is higher or is given [Amount]
	local Connection
	Connection = Instance.ChildAdded:Connect(function()
		if (#Instance:GetChildren() => Amount) then
			--/If you won't disconnect it, the function will
			--\keep firing every time a child is added, not needed
			Connection:Disconnect()
	
			Signal:Fire()
			Signal:Destroy()
		end
	end)

	--/Yield until all children exists
	Signal.Event:Wait()
end

WaitUntilInstanceContainsGivenAmountOfChildren(script, 1e999)

This is site-written so i have no idea whether this works but you get the idea, if this is not what you were looking for then :)

Sources

BindableEvents

Event Disconnecting

ChildAdded

4 comments

0

Is there any way to get the amount of parts loaded in? I've seen games pull this off like Pool Tycoon 4 where it says "Loading 0/100 Zone 1/2"

0

Also the plot is being loaded in based off a datastore (table) so its all being newly instanced.

0

wait so if it's loaded from data store, you are looping through parts to create them right? Why don't you just add +1 to counter every loop index to increase amount of loaded parts and the total would be like #table

0

And for waiting to ploat to load you can just use events to fire that the loop has ended after the loop and you don't need no waiting for the path

This discussion is preserved as it was. New answers, comments, and votes are closed.