PreloadAsync is not preloading assets?

I have the following code in a module that is supposed to load assets and print them if chosen. However, they do not print.

local module = {}

function Callback(ContentID, Status, PrintStuff)
	if PrintStuff == true then
		if Status == Enum.AssetFetchStatus.Success then
			print("Content ("..ContentID..") successfully loaded.")
		elseif Status == Enum.AssetFetchStatus.Failure then
			print("Content ("..ContentID..") failed to load.")
		end
	end
end

function module:PreloadAssets(ContentTable, ShouldPrint)
	if ShouldPrint == nil then ShouldPrint = false end
	print(ShouldPrint)
	if ShouldPrint then
		game:GetService("ContentProvider"):PreloadAsync(ContentTable, Callback)
	else
		game:GetService("ContentProvider"):PreloadAsync(ContentTable)
	end
end

return module

What prints is basically ShouldPrint, true if chosen, or false if nil. But the first 2 prints do not get outputted. What should I do?

First, make sure that PrintStuff is true.

Secondly, you don’t need to add another if statement if the AssetFetchStatus is false. Just do

if Status == Enum.AssetFetchStatus.Success then
			print("Content ("..ContentID..") successfully loaded.")
		else
			print("Content ("..ContentID..") failed to load.")
		end

Try these two things and see if prints.

Made sure of everything plus changes made. Nothing.

That’s strange. Try printing out Enum.AssetFetchStatus.Success to make sure it is true. That’s the only thing left I can think of.

Ooooh I just figured it out. Just like always, I am dumb!


What I didn’t do was add the code that does the same, except PrintStuff is false. Anyway, thank you so much for helping, @Friendly4Crafter!

if PrintStuff == true then
		
		if Status == Enum.AssetFetchStatus.Success then
			print("Content ("..ContentID..") successfully loaded.")
		else
			print("Content ("..ContentID..") failed to load.")
		end
	end
where false
1 Like