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

This loading bar only works on studio and not game, how can I fix it?

Asked by
aindev 4
5 years ago

I am making a loading bar in the bottom left corner of the game and for some reason it is not working, how can I fix this?

local contentprovider = game:GetService("ContentProvider")
while wait(1) do
    if contentprovider.RequestQueueSize == 0 then
        script.Parent.Text = "Loaded!"
        wait(1)
        script.Parent.Parent:Destroy()
    end
end
0
1. Script type 2. Don't use wait() as a condition 3. Don't use RequestQueueSize for loading bars User#19524 175 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Use Remotes.

Server:

local contentprovider = game:GetService("ContentProvider")
contentprovider.Changed:Connect(function()
if contentprovider.RequestQueueSize == 0 then
game:GetService("ReplicatedStorage").RemoteEvent:FireClient(game.Players.LocalPlayer)
end
end)

Client:

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(function()
local plr = game.Players.LocalPlayer
plr.PlayerGui.NameOfYourGuiHere.ReferenceYourTextLabelHere.Text = "Loaded!"
wait(1)
plr.PlayerGui.NameOfYourGuiHere:Destroy()
end)
Ad
Log in to vote
0
Answered by 5 years ago

If you're doing it on the player or on local scripts, Then it doesn't work because on the studio it's not filtering enabled, but on the game, it's filtering enabled.

Answer this question