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

How do I manipulate the PlayerGui after I preload with ContentProvider?

Asked by 9 years ago
local Menu = script.Parent.StartMenu
local Frame = Menu.Frame
local Pic = Frame.Huh
local ContentProvider = game:GetService("ContentProvider")

while true do
    wait()
    Pic.Rotation = Pic.Rotation + 5
end 

local function LoadAssets(AssetList)
    -- Takes an asset list and preloads it. Will not wait for them to load. 

    for _, AssetId in pairs(AssetList) do
        ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId)
    end

    while ContentProvider.RequestQueueSize > 0 do
        wait(0.1)
    end
end

LoadAssets({316291477, 328017149, 328371540, 198614198})

wait(0.1)

Pic.Visible = false

That is my script. After I load it, it does not let me do anything. An example I put was making my spinning icon invisible, but it does not work. Do I need a wait somewhere in the script that I missed?

1 answer

Log in to vote
0
Answered by 9 years ago

Your while loop on Line 6 is the problem.

While loops basically pause the script until they're done, so if you're going to make an endless loop, you need to:

A: Move the while loop to the bottom of your script.

B: Put the while loop into a new script.

But to fix your actual problem:

In the while loop that repeats until RequestQueueSize == 0, you need to put the rotation there as well, and the remove the while loop on Line 6, so:

local Menu = script.Parent.StartMenu
local Frame = Menu.Frame
local Pic = Frame.Huh
local ContentProvider = game:GetService("ContentProvider")

local function LoadAssets(AssetList)
    -- Takes an asset list and preloads it. Will not wait for them to load. 

    for _, AssetId in pairs(AssetList) do
        ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId)
    end

    while ContentProvider.RequestQueueSize > 0 do
        wait(0.1)
    Pic.Rotation = Pic.Rotation + 5
    end
end

LoadAssets({316291477, 328017149, 328371540, 198614198})

wait(0.1)

Pic.Visible = false

Hopefully I addressed your problem correctly :)

0
Thank you so much! It worked! ZaltherusKenobi 15 — 9y
Ad

Answer this question