Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Am I using the 'Preload' method correctly in my code?

I am currently using the Preload method to prevent bugs from occurring later on in my Admin Commands system in the future, however, to my surprise, it is taking along time, and I am not sure if I am using it correctly, as I have set it up to repeat waiting until the asset has Preloaded, sadly, I can not provide any Output, as it just prints Preloading Assets.. the starting of execution, here is the code I am currently using:

print("Preloading Assets..")
local Preload = {154482026,109163377,109165391,172729916,151363261,151360795,177146457,134086163,106708040,5207053,43803419,43803430,94024832,86089361,145422684,175215264,174589931,156434403,130768080,161196747,180236172,143512547,143947880,155107435,154362806,130764066,176442243,191819419,157671361,197321696,155213085}
for i,v in pairs(Preload) do
if game:GetService("ContentProvider") then
repeat game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..v)
wait(1/19)
until game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id="..v) 
print("PRELOADED",v)
end
end
print("Finished Preloading")

1 comment

0

So you are saying it works, but just takes a long time? I know your far ahead of me in scripting, but I feel like the repeat (1/19) is maybe so fast that its making it lag...Keep in mind I don't exactly know how Preload works, but I thought I'd give you some suggestions

1 answer

The preload function runs asynchronously, so you shouldn't have much of a problem.

A better way to make sure everything has loaded is to RequestQueueSize property, and wait till it gets to 0. This would also be useful if you wanted to show your user how long they need to wait for everything to load.

2 comments

0

How would I accomplish this? Er, or, as I should say, how would I go about doing this?

0

Really? I never knew about that property.

This discussion is preserved as it was. New answers, comments, and votes are closed.