Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to prevent "Unable to cast double to Content"?

Asked by
ItsMeKlc 235 Moderation Voter
8 years ago

This script bellow is made to preload any assets within a model, and it works when there is just one of each item, but if there is more than on of an item (hat, decal ect.) it gets stuck and just says "ContentProvider:Preload() failed for " "Unable to cast double to Content" How can I prevent this?


local function WaitForAssetsToLoad() while (ContentProvider.RequestQueueSize > 0) do wait(0.1) end end local function LoadAssets(AssetList) for _, Asset in pairs(AssetList) do if Asset.ClassName == "StringValue" then ContentProvider:Preload(Asset.Value) elseif Asset.ClassName == "Sound" then ContentProvider:Preload(Asset.SoundId) elseif Asset.ClassName == "Decal" or Asset.ClassName == "Texture" then ContentProvider:Preload(Asset.Texture) elseif Asset.ClassName == "Animation" then ContentProvider:Preload(Asset.AnimationId) elseif Asset.ClassName == "Shirt" then ContentProvider:Preload(Asset.ShirtTemplate) elseif Asset.ClassName == "Pants" then ContentProvider:Preload(Asset.PantsTemplate) elseif Asset.ClassName == "ShirtGraphic" then ContentProvider:Preload(Asset.Graphic) elseif Asset.ClassName == "CharacterMesh" or Asset.ClassName == "SpecialMesh" then ContentProvider:Preload(Asset.MeshId) ContentProvider:Preload(Asset.TextureId) elseif Asset.ClassName == "ImageLabel" or Asset.ClassName == "ImageButton" then ContentProvider:Preload(Asset.Image) else LoadAssets(Asset:GetChildren()) end end WaitForAssetsToLoad() end
0
I think I could make a table that adds each assest and wont add it twice but im not sure hot to do so ItsMeKlc 235 — 8y

Answer this question