When executing the following code inside a normal script
Assets = { "https://web.roblox.com/library/1818131072/Gun-Reload", "https://web.roblox.com/library/1818128535/Gun-Sprint", "https://web.roblox.com/library/1818040825/The-real-aim" } game:GetService("ContentProvider"):PreloadAsync(Assets)
I get this error:
https://gyazo.com/eabd84fc7dfe7a1887e9cc9c5e10600f
Why?
You and saSlol2436 are doing it wrong. Roblox decided to change on how you preload assets. Now, you have to create the instance and link it to the content and then pass the instance. I think it's utterly stupid.
http://wiki.roblox.com/index.php?title=API:Class/ContentProvider/PreloadAsync
So here's what you gotta do. This will only work if all of your assets are images.
local ContentProvider = game:GetService("ContentProvider") local Assets = {} for i,Asset in pairs (Assets) do local ImageLabel = Instance.new("ImageLabel") ImageLabel.Image = Asset ContentProvider:PreloadAsync(ImageLabel) end
It isn't tested because I can't be bothered to open RobloxStudio.
If this solved your problem, accept my answer or feel my wrath.
What I think you have done wrong is that you haven't iterated
(or a fancy word for loop) the array
(just another word for table or list).
I just added two more lines of code
.
local Assets = { "https://web.roblox.com/library/1818131072/Gun-Reload", "https://web.roblox.com/library/1818128535/Gun-Sprint", "https://web.roblox.com/library/1818040825/The-real-aim" } for _,asset in pairs(Assets) do game:GetService("ContentProvider"):PreloadAsync(asset) end
By the way, I recommend using local
variables when declaring
them because they are slightly faster than a variable that is declared without the local
syntax
Please accept this answer if it helped you