Hello,

I have a table with model hashes to request, but whenever I run RequestModel inside table iterator, it doesnt get to the end of the loop. The issue is somewhat inconsistent, sometimes I only get the print messages once or twice, sometimes I get them five or six times.

local tblModelHashesToRequest = {};

-- replaced object hashes with general "hash" keyword
tblModelHashesToRequest[hash] = true;
tblModelHashesToRequest[hash] = true;
-- and so on...

for hash, _ in pairs(tblModelHashesToRequest) do
	print("request!")
	RequestModel(hash);
	
	while not HasModelLoaded(hash) do
		Wait(1);
	end
	
	print("done!")
end

Is there something wrong in the logic or am I requesting too much at once?

It is likely because HasModelLoaded never returns true for a specific model.
Either because the model does not exist, is broken, or cannot be requested.
You should use IsModelInCdimage to ensure the model is relevant, and maybe a timeout if HasModelLoaded is too slow to return true.

1 Like

Thanks for the response, IsModelInCdimage indeed helped finishing the iteration.