My loading is not good


I feel like using guibase and the other things I did are not loading properly. What do you think I should do?

Here’s a part of my almost perfect working loading code:

for i, asset in ipairs(assets) do
	if asset.Name == "exe_storage" or asset:IsDescendantOf(game.ReplicatedStorage.exe_storage) then continue end
	local starttime = tick()
	local percent = i / maxassets

	PText.Text = math.floor(percent * 100) .. "%"
	TS:Create(PBar, TweenInfo.new(1), {Size = UDim2.new(percent, 0, 1, 0)}):Play()

	local success, err = pcall(function()
		local loaded = false

		-- Use task.delay for timeout warning
		local timeoutWarned = false
		local timeoutConn = task.delay(5, function()
			if not loaded then
				timeoutWarned = true
				warn("Asset loading timeout: ", asset)
			end
		end)

		CP:PreloadAsync({asset})
		loaded = true

		-- No need to cancel task.delay, just set loaded = true before timeout triggers
	end)

	if not success then
		warn("Failed to preload asset: ", asset, err)
	end

	-- Pause every 500 assets to avoid blocking
	if i % 500 == 0 then
		wait(0.1)
	end
end
1 Like