This preloader script I made isn’t working, and it’s outputting, " [Unable to cast to Array]". How can I fix that?
CODE
local ContentProvider = game:GetService("ContentProvider")
local assets = Instance.new("Folder", script) -- create a folder called assets in the script.
assets.Name = "Assets"
local animations = Instance.new("Folder", assets) -- create a folder called animations inside the assets folder
animations.Name = "Animations"
local animationIDs = {
"rbxassetid://5645167603" -- animation ids to be loaded
}
for i = 1, #animationIDs do -- loop thorugh all the ids and create animation instances for them
local animation = Instance.new("Animation")
animation.Name = "Animation"..i
animation.AnimationId = animationIDs[i]
animation.Parent = animations -- add this animation to the animations folder inside assets
end
warn("Preloading assets...")
for _, content in pairs(assets:GetChildren()) do -- loop through all of the content (animations)
for __, asset in pairs(content:GetChildren()) do -- loop through all of the content (in this case animations) and preload them
ContentProvider:PreloadAsync(asset) -- error is here, but this is a child of assets, I don't know why it's error'ing.
end
end
print("Preloaded assets!")