How to wait for all parts to load in?

I’ve been trying to make a loading script because players are spawning before the map is fully loaded.

The map generation works by procedurally generating random terrain as tiles.

I need something that will wait for each tile to be loaded in.

I’ve attempted to use descendant added and waitforchild. None of those worked.

If anyone knows a way I can do this please tell me. If one of the things I mentioned above does work please tell me how to make it work.

Here is my script:

local loadEvent = game:GetService("ReplicatedStorage"):WaitForChild("Load")
local player = game:GetService("Players").LocalPlayer
loadEvent.OnClientEvent:Connect(function(folderToLoad,expectedNumber,anchorPlayer)
	local character = player.Character or player.CharacterAdded:Wait()
	if anchorPlayer then
		local torso = character:WaitForChild("Torso")
		torso.Anchored = true
	end
	
	if anchorPlayer then
		local torso = character:WaitForChild("Torso")
		torso.Anchored=false
	end
end)

The empty space is where I would put the script that waits for all parts to be loaded in.

1 Like

You will want to use the ContentProvider service: ContentProvider | Documentation - Roblox Creator Hub

It is used to create loading screens based on actual asset loading information.

Is has a property called RequestQueueSize that you can use to check and see how much asset loading is left to be done.

13 Likes