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

My loading gui stops working if something fails to load once?

Asked by 4 years ago

Hello, i have made a loading gui in my game that, once the game fully loads, dissapears, however, if something fails to load, the gui stops working even if the game fully loads Here is my code:

local frame = script.Parent.Frame
local base = frame.Base
local bar = base.Bar
local indicator = base.Indicator
local skip = base.Skip
local queue = game.ContentProvider.RequestQueueSize

game:GetService("RunService").Stepped:Connect(function()
    indicator.Text = "Loading Assets... (" .. queue .. ")"
    bar.Size = UDim2.new(1/queue, 0, 1, 0)
    if queue == 0 then
        indicator.Text = "Assets Loaded!"
        bar.Size = UDim2.new(1, 0, 1, 0)
        wait(1)
        frame:TweenPosition(UDim2.new(0, 0, 1, 0))
    end
end)

can anyone help me here???

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

When using parentheses, you need to make it a long string. Here:

local frame = script.Parent.Frame
local base = frame.Base
local bar = base.Bar
local indicator = base.Indicator
local skip = base.Skip
local queue = game.ContentProvider.RequestQueueSize

game:GetService("RunService").Stepped:Connect(function()
    indicator.Text = [[Loading Assets... (]] .. queue .. [[)]]
    bar.Size = UDim2.new(1/queue, 0, 1, 0)
    if queue == 0 then
        indicator.Text = "Assets Loaded!"
        bar.Size = UDim2.new(1, 0, 1, 0)
        wait(1)
        frame:TweenPosition(UDim2.new(0, 0, 1, 0))
    end
end)
Ad

Answer this question