How to yield script until every part has loaded?

Instead of trying to wait for every part to load in workspace you could make use of .DescendantAdded

Example:

local function partAdded(v)
if v:IsA("BasePart") then
		if v.Name == "KILLBRICK" then
			task.spawn(function()
				v.Touched:Connect(function(hit)
					if hit.Parent:FindFirstChild("Humanoid") then
						hit.Parent.Humanoid:TakeDamage(math.huge)
					end
				end)
			end)
		end
	end
end
workspace.DescendantAdded:Connect(partAdded)
for _, v in workspace:GetDescendants() do partAdded(v) end

If a part loads in workspace after the script is executed it will attempt to bind it.

2 Likes