i have a loading ui but it loads eerything i only want it to load workspace and fast how can i do it
script:
for i = 1, #assets do
local asset = assets[i]
if db == false then
game:GetService("ContentProvider"):PreloadAsync({asset,game.ReplicatedStorage, Players.LocalPlayer.PlayerGui})
gui.Frame.percent.Text = math.round(i / #assets * 100).."%"
gui.Frame.db.Text = "Loading: ["..i.."/"..#assets.."] "..asset.Name
end
coroutine.resume(coroutine.create(function()
while #assets do
pcall(function()
gui.Frame.TextLabel.Text = "Loading"
task.wait(.3)
gui.Frame.TextLabel.Text = "Loading."
task.wait(.3)
gui.Frame.TextLabel.Text = "Loading.."
task.wait(.3)
if #assets >= 90 then
gui.Frame.TextLabel.Text = "Nearly There..."
end
end)
task.wait(.3)
if db == true then
break
end
end
gui:Destroy()
conn:Disconnect()
end))
end
Try running the script, but note that I am unable to test it as I don’t have access to the GUI. Additionally, I want to remind you that I didn’t write this script in a studio environment, so there’s a possibility that it may not work as intended or simply not work. Make me know if that not worked.
local ContentProvider = game:GetService("ContentProvider")
local Workspace = game:GetService("Workspace")
local function updateUI(i)
gui.Frame.percent.Text = math.round(i / #Workspace:GetDescendants() * 100) .. "%"
gui.Frame.db.Text = "Loading: [" .. i .. "/" .. #Workspace:GetDescendants() .. "] " .. Workspace:GetDescendants()[i].Name
end
local function loadingRoutine()
local assets = Workspace:GetDescendants()
for i = 1, #assets do
if db == true then
break
end
updateUI(i)
ContentProvider:PreloadAsync({assets[i]})
task.wait(.3)
if i >= 90 then
gui.Frame.TextLabel.Text = "Nearly There..."
end
end
gui:Destroy()
conn:Disconnect()
end
coroutine.resume(coroutine.create(loadingRoutine))