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

How do i preload pictures?

Asked by 6 years ago
Edited 6 years ago

Hello i am trying to preload pictures in my game. I have four image ID's in string values. However only two of the pictures are working and the others are just white and giving an error saying they couldn't be loaded. So heres my script and it gives me this error:

My error: Unable to cast to Array Script 'Players.bondhemlig.PlayerGui.PictureLoading', Line 12 - local LoadAssets Script 'Players.bondhemlig.PlayerGui.PictureLoading', Line 24

I don't know what this error means so help would be appreciated.

Local Script:

repeat
wait(0.5)

print("DO")

local ContentProvider = game:GetService("ContentProvider")

local function LoadAssets(AssetList)
    wait()
    for _, AssetId in ipairs(AssetList) do
        print(AssetId)
        ContentProvider:PreloadAsync("http://www.roblox.com/asset/?id=" .. AssetId)
    end
end

local Pics={}

for i,v in pairs(game.Workspace.Values.MPics:GetChildren())do
    if v:IsA("StringValue")then
        table.insert(Pics,v.Value)
    end
end

LoadAssets(Pics)
until ContentProvider.RequestQueueSize <= 0
script:Remove()

Help would be appreciated thanks!

0
PreloadAsync takes instances, not strings. OldPalHappy 1477 — 6y
0
ok, but how do i do that, do i like need to create my values in the script? bondhemlig 20 — 6y
0
? bondhemlig 20 — 6y
View all comments (4 more)
0
I still don't get it.. bondhemlig 20 — 6y
0
something like PreloadAsync(Player.PlayerGui.ImageLabel) RubenKan 3615 — 6y
0
oh, ok. bondhemlig 20 — 6y
0
ok, but i have like a gui where i have made two imagebuttons does this mean i need to instance them and like also change their properties as well? Can't you just preload the ID with like a string? bondhemlig 20 — 6y

Answer this question